Giter Site home page Giter Site logo

Comments (4)

mnishiguchi avatar mnishiguchi commented on August 30, 2024 2

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.

mnishiguchi avatar mnishiguchi commented on August 30, 2024 1

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.

tashirosota avatar tashirosota commented on August 30, 2024

@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.

tashirosota avatar tashirosota commented on August 30, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.