Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List as map #1

Closed
wants to merge 1 commit into from
Closed

List as map #1

wants to merge 1 commit into from

Conversation

arvenil
Copy link

@arvenil arvenil commented Jan 26, 2016

Hi

ItemsAsMap is small addition to allow to get all items from a bucket as an indexed map. Without this I would need to reiterate through slice from Items()

Let me know what you think

@joyrexus
Copy link
Owner

Yeah, in an earlier incarnation of buckets I had a method called ItemsMap that did just this, but decided to drop it for two reasons:

  1. You can build an indexed map pretty easily using the Map, MapPrefix, and MapRange methods, which should be just as performant. (I can sketch out an example gist if you'd like.) In many cases, you'd want to do it this way anyway so as to be able to cast the returned value in addition to casting the key as a string.
  2. Since I'm using the term "Map" in a number of other methods and using it to mean "map over items" (i.e., the functional sense rather than the sense of a hash-like structure), I thought having an ItemsMap method was a little confusing.

In sum, to keep things simple and consistent (method name wise) I'd prefer not to add this in.

Perhaps I should add a few more examples demonstrating how to use the existing Map* methods?

@joyrexus joyrexus closed this Feb 10, 2016
@arvenil
Copy link
Author

arvenil commented Feb 10, 2016

You are right. Map is fine to do that. Probably Items() was/is confusing to me as you use this one, then realize you need keys as indexes so you immediately think about ItemsWithKeyAsIndex(). Or, you know, now Items() looks redundant too as you can do the same with Map ;)

Perhaps I should add a few more examples demonstrating how to use the existing Map* methods?

As you wish - I'm good now :) Maybe there will be a future reader that is going to have similar thoughts, so an example for Map with comment "you can use it to produce indexed map like this" could work for him :)

Thanks for response :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants