1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-03-16 04:10:01 +01:00

[ruby/en] add .map($:method) sintax in blocks context

This commit is contained in:
Claudio Secco 2020-05-02 16:09:41 -03:00
parent a67f4663eb
commit d9ee9ce390

View File

@ -327,6 +327,11 @@ puts doubled
puts array puts array
#=> [1,2,3,4,5] #=> [1,2,3,4,5]
# another useful sintax is .map(&:method)
a = ["FOO", "BAR", "BAZ"]
a.map { |s| s.downcase } #=> ["foo", "bar", "baz"]
a.map(&:downcase) #=> ["foo", "bar", "baz"]
# Case construct # Case construct
grade = 'B' grade = 'B'