Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,7 @@
|
|||
values = [1, 2, 3]
|
||||
|
||||
new_values = values.map do |number|
|
||||
number * 2
|
||||
end
|
||||
|
||||
puts new_values #=> [2, 4, 6]
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
values = [1, 2, 3]
|
||||
|
||||
def double(number)
|
||||
number * 2
|
||||
end
|
||||
|
||||
# the `->double(Int32)` syntax creates a proc from a function/method. argument types must be specified.
|
||||
# the `&proc` syntax passes a proc as a block.
|
||||
# combining the two passes a function/method as a block
|
||||
new_values = values.map &->double(Int32)
|
||||
|
||||
puts new_values #=> [2, 4, 6]
|
||||
Loading…
Add table
Add a link
Reference in a new issue