I want to do something similar to this:
def creator()
return lambda { |arg1, arg2 = nil|
puts arg1
if(arg2 != nil)
puts arg2
end
}
end
test = creator()
test('lol')
test('lol', 'rofl')
I get a few syntax errors:
test.rb:2: syntax error
return lambda { |arg1, arg2 = nil|
^
test.rb:3: syntax error
test.rb:7: syntax error
test.rb:14: syntax error
is this possible in ruby? i want to set a default value for a parameter to a lambda function