Wednesday 12 September 2012

tap


each element
[1,2,3,4,5].each {|a| a.tap {|t| p t + 10}}
 =>
11
12
13
14
15

Tap the array

[1, 2, 3].tap(&:reverse!)
 => [3, 2, 1]


No comments:

Post a Comment