Equivalent of “pass” in Ruby

No, there is no such thing in Ruby. If you want an empty block, method, module, class etc., just write an empty block:

def some_method
end

That’s it.

In Python, every block is required to contain at least one statement, that’s why you need a “fake” no-op statement. Ruby doesn’t have statements, it only has expressions, and it is perfectly legal for a block to contain zero expressions.

Leave a Comment