Is there a way to make a method that can accept a parameter, but can also be called without one, in which case the parameter is regarded nil
like the following?
some_func(variable) some_func
Optional parameters are defined at the end of the parameter list, after any required parameters. If the caller provides an argument for any one of a succession of optional parameters, it must provide arguments for all preceding optional parameters. Comma-separated gaps in the argument list aren't supported.
Unlike positional parameters, the parameters' name must be specified while the value is being passed. Curly brace {} can be used to specify optional named parameters.
def some_func(variable = nil) ... end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With