Is it possible to send nothing to an object?
Let me elaborate. For instance I could have something like this:
val = some_stack.include?(some_val) ? some_val : nil
obj1.obj2.send(val).obj3.obj4
The above call wont’t work because nil is not a symbol. So the solution is:
if val.nil?
obj1.obj2.obj3.obj4
else
obj1.obj2.send(val).obj3.obj4
end
However I’m not too fond of this. Is there any other way?
I’m not aware of any method that returns
selfwithout taking any arguments (but I might be overlooking something), but there’s no reason you couldn’t monkeypatch one into the class you’re using: