Synonyms of methods in Ruby

I get acquainted with Ruby, and for the first time I see method synonyms in the standard library. So far I have found those that are in the Enumerable module:

collect <-> map
detect <-> find
include <-> member
etc.

Other modules may also contain synonymous methods. Why are they there? Is it some kind of backward compatibility? Or is it a feature of the language, so the programmer can choose between different options depending on the context, so that the program looks like plain English?

+3
source share
2 answers

, . Ruby Smalltalk. Smalltalk collect . map, Ruby map, .

. http://en.wikipedia.org/wiki/Map_function.

+3

, , , (, map, grep .., , Perl).

, , , . Rails associations, , find SQL-, detect find/detect.

+3

Source: https://habr.com/ru/post/1739228/


All Articles