Lately I had an idea.
Methods take default arguments like so:
def foo(i = ‘blee’, j = ‘blabalaa’)
I had a need to call foo() in my code, but change the default
to the j argument. There may be several ways, like redefining:
def foo(i = ‘blee’, j = ‘foofoo’)
One could also use a hash instead.
But I myself, thought about this:
foo.j = ‘dumdedum’
Of course this does not work. But my question is, would this
work in Ruby in theory? And if not, why can it not work?
I am thinking that methods could be treated as pseudo objects.
We also can already create objects from methods via method(:name)
(I think it is of UnboundMethod class)
I am wondering, if arguments to methods are data, why couldn’t
they be (pseudo)objects at the same time as well?