Just a little curiosity: If method definitions (def foo; end') were to return a symbol representing the method's name (:foo’ in this case)
rather than just nil, would this be possible?
discussions).
Could you point me to one of those discussions? I wonder why such a
proposal was turned down.
As a big proponent of making def return something useful, it was turned
down in part because what would def return to be passed into private
with:
class Klass
private def self.foo
“Klass.foo”
end
end
If you simply do :foo, then you would be applying private to Klass#foo
– which isn’t what you want. But returning more than :foo isn’t kosher
either since private doesn’t (at this point) know what to do with it.
I think Matz would be at least partially in favour of this if we could
figure out something useful and lightweight to return that wouldn’t
prevent the above code.
I think Matz would be at least partially in favour of this if we could
figure out something useful and lightweight to return that wouldn’t
prevent the above code.
Peter V. may have firgured out the best way. He wrote a
patch to return a struct. You can find it here: