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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You always have
endstatements, sopassis not needed.Ruby example:
Ruby 3.0
As of Ruby 3.0, so-called "
endless" method definitions are now supported — we no longer requireendstatements 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:Alternatively, there has always been an uglier one-line option using the much-hated semicolon:
Note that this doesn’t really change anything about the first solution except how the code can be written.