Pass name of function as a block
In Ruby it is possible to pass a function name instead of a block to a function expecting a block using &method
in the last argument.
For example:
def blocky_fun(foo)
bar = "hello #{foo}"
yield(bar)
end
blocky_fun('blocky', &method(:puts))
The result of the above would be that the puts
function will be called with "hello blocky" as the first argument.