Let's say I have a ruby method:
def blah(foo=17)
...
end
In the code, I want to call blah with a specific argument "blah (a)" or call blah using my default argument "blah ()" Is there a way to do this without specifying the method name twice? I try to avoid:
if a.nil?
blah()
else
blah(a)
end
Because it makes the code more complex than it is. Best I can come up with (not a test):
args=[]
args << a unless a.nil?
a.send :blah, args
source
share