No, there is no other way than to either explicitly return nil or evaluate another expression that implicitly evaluates the value of nil (for example, () ).
If you want to add some kind of semantic marker that shows that you explicitly want to ignore the return value, you can come up with some kind of convention for it, for example:
def f(param)
or
def f(param)
which will make these cases easy to grep capable of, but will probably help little in understanding.
This is the Ruby design choice that it shares with many other expression-based languages: the value of the block / subroutine / procedure / function / method is the value of the last expression evaluated inside the block. So how does it work in Lisp, for example.
Please note that there are other options. For instance. in Smalltalk, the return value of the method must be explicitly returned using the ↑ operator, otherwise the return value is nil . In E, which is largely security-oriented, this is even a conscious design choice: automatically returning the value of the last expression is considered a potential information leak.
source share