J
James H.
Suppose I had two methods:
# First method
def my_first_method(b)
yield b
end
# Second method
def my_second_method(&block)
block.call
end
I know that the block in the 2nd example is converted to a Proc object,
but a Proc object (to my newb eyes) doesn't seem to hold any advantages
that might make me want to use the latter method.
I was wondering if there are specific advantages to using the &block
convention or yield()ing a block? Is it merely a matter of preference
and or convention?
James
# First method
def my_first_method(b)
yield b
end
# Second method
def my_second_method(&block)
block.call
end
I know that the block in the 2nd example is converted to a Proc object,
but a Proc object (to my newb eyes) doesn't seem to hold any advantages
that might make me want to use the latter method.
I was wondering if there are specific advantages to using the &block
convention or yield()ing a block? Is it merely a matter of preference
and or convention?
James