x = proc { |e| e + 1 }
{ |e| e + 1 }
is a function
def method_accepting_proc(variable, proc)
proc.call(variable)
end
method_accepting_proc(2, x) =># 3
def method_using_block(variable, &block)
block.call(variable)
end
def method_using_block(variable)
yield(variable)
end
method_using_block(2) do |x|
x + 1
end
=># 3