advanced/block_as_arg.rb
tests/_examples/advanced/block_as_arg.rb in the metorex repository.
# Test passing a block as an argument using & syntax
def apply(&blk)
blk.call(5)
end
b = lambda { |x| x * 3 }
puts apply(&b)
Output:
15
tests/_examples/advanced/block_as_arg.rb in the metorex repository.
# Test passing a block as an argument using & syntax
def apply(&blk)
blk.call(5)
end
b = lambda { |x| x * 3 }
puts apply(&b)
Output:
15