Comments (4)
NP! Actually I have a few more things to say ๐
Is it intentional to output differently between maps and lists?
iex> REnum.to_a(a: 1, b: 2, c: 2, d: 4)
[{:a, 1}, {:b, 2}, {:c, 2}, {:d, 4}] #<-- list of tuples
iex> REnum.to_a(%{a: 1, b: 2, c: 2, d: 4})
[[:a, 1], [:b, 2], [:c, 2], [:d, 4]] #<-- list of lists
Ruby to_a
implies "to array" and we do not have arrays in Elixir. Maybe we could skip implementing some Ruby methods that do not make sense in Elixir world?
With that all said, it is a design decision. It is all your call ๐
UPDATES
- My apologies, I realized that you already delegate it to
Enum.to_list/1
in an PR and it solves it!
from ex-r_enum.
Ruby does not have tuples. Elixir has tuples and linked lists.
I believe tuples are more efficient than lists in Elixir.
Key-value pairs are always two elements long so I wonder if there is any benefit of using list as a data structure there ๐ค
In the end, it is about a design decision so if list makes sense in this context, I guess list is fine ๐
from ex-r_enum.
@mnishiguchi
I wanted it to behave like Ruby as much as possible! But I'm a little worried about this.
I think it's more natural to call to_list too.What do you think?
https://docs.ruby-lang.org/ja/latest/method/Hash/i/to_a.html
from ex-r_enum.
@mnishiguchi
I thought about it overnight, but the behavior on to_list seems more natural in Elixir, so I'll try to adjust it accordingly!
Such an opinion is very helpful. Thank you!
from ex-r_enum.
Related Issues (8)
- Maybe hide some implementation details? HOT 4
- Ruby's Array and ActiveSupport has many difficult methods. HOT 5
- Maybe skip implementing Ruby `Array#zip`? HOT 1
- TODO: Contribution Guide
- TODO: Introductory article written in English.
- usage image
- hexdocsใฎ็ฎๆฌกใใๅ้ขๆฐใธใธใฃใณใใงใใชใ HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ex-r_enum.