Why is Ruby’s array.map () is also known as array.collect ()?

Whenever I see Ruby code saying:

arrayNames.collect {... }

< p>I forgot what I collected, I have to find out what it is, and found that it is the same as map().

Map, I can understand, to map 1 byte to a pixel, the function is Map x to y, a 2 to 4, 5 to 25, etc. But where does the name “collect” come from? Maybe this will help remember what the “collect” method is.

to add to other answers , It is an inside joke in Smalltalk:

>Inject: Enter:
>Collect:
>Select:
>Reject:
>Detect:

Discovery mode?

Whenever I see Ruby code saying:

arrayNames.collect {... }< /pre> 

I forgot what was collected, I had to find out what it was, and found that it is the same as map().

Map, I can understand, maps 1 byte to one Pixel, the function is to map x to y, a 2 to 4, 5 to 25 and so on. But where does the name "collect" come from? Maybe this will help memorize what the "collect" method is.

To add to the other answers, it is an inside joke in Smalltalk: < p>

>Inject: Enter:
>Collect:
>Select:
>Reject:
>Detect:

Discover mode?

Leave a Comment

Your email address will not be published.