mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-13 18:24:39 +02:00
[ruby/en] add .map($:method) sintax in blocks context
This commit is contained in:
@@ -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'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user