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:
parent
a67f4663eb
commit
d9ee9ce390
@ -327,6 +327,11 @@ puts doubled
|
||||
puts array
|
||||
#=> [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
|
||||
grade = 'B'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user