Equivalent of “pass” in Ruby

keyword, ruby

Solution

You always have `end` statements, so `pass` is not needed.

Ruby example:

def some_function()
    # do nothing
end

Ruby 3.0

As of Ruby 3.0, so-called "`end`less" method definitions are now supported -- we no longer require `end` statements with every single method definition. This means the most concise way of expressing an empty method like the example above is now arguably something like this:

def some_function = nil

Alternatively, there has always been an uglier one-line option using the much-hated semicolon:

def some_function; end

Note that this doesn't really change anything about the first solution except how the code can be written.

Problem

In python there is a `pass` keyword for defining an empty function, condition, loop, ... Is there something similar for Ruby? Python Example: ``` def some_function(): # do nothing pass ```

Original source