Tuesday, 17 July 2012

no block given (yield) (LocalJumpError)

This error will occur when working with blocks.

When you used the 'yield' statement inside the method and didn't pass block as parameter then it will raise the 'no block given (yield) (LocalJumpError)' error.

def my_method
yield
end

puts my_method

In the above method call we are not passing parameter as a block so it will throw '(LocalJumpError) error'.

Here is the correct way to pass block as a parameter


def my_method
yield
end

puts my_method{puts 'Hi Uma Mahesh'}


Thank You,
Uma Mahesh.

No comments:

Post a Comment