This makes the following two statements work as intended:
p String0.new("foo").foo # => 123
p String.new("foo").foo # => 123
The following doesn't work though:
p "foo".foo
p eval %{"foo".foo}
undefined method `foo' for "foo":String (NoMethodError)
Has somebody an idea if it is possible to make the ruby parser use
the
new String class somehow? I assume there is no way to make this work
but
then: I'd be happy if somebody proves me wrong.
This makes the following two statements work as intended:
p String0.new("foo").foo # => 123
p String.new("foo").foo # => 123
The following doesn't work though:
p "foo".foo
p eval %{"foo".foo}
undefined method `foo' for "foo":String (NoMethodError)
Has somebody an idea if it is possible to make the ruby parser use
the
new String class somehow? I assume there is no way to make this work
but
then: I'd be happy if somebody proves me wrong.
This makes the following two statements work as intended:
p String0.new("foo").foo # => 123
p String.new("foo").foo # => 123
The following doesn't work though:
p "foo".foo
p eval %{"foo".foo}
undefined method `foo' for "foo":String (NoMethodError)
Has somebody an idea if it is possible to make the ruby parser use
the
new String class somehow? I assume there is no way to make this work
but
then: I'd be happy if somebody proves me wrong.
This makes the following two statements work as intended:
p String0.new("foo").foo # => 123
p String.new("foo").foo # => 123
The following doesn't work though:
p "foo".foo
p eval %{"foo".foo}
undefined method `foo' for "foo":String (NoMethodError)
Has somebody an idea if it is possible to make the ruby parser use
the new String class somehow? I assume there is no way to make this work
but then: I'd be happy if somebody proves me wrong.
The above question was inspired by certain posts to the monkey-thread
and the idea of stacked classes/methods, the proposal of module-
specific hacks and the idea of Module.import/rename (I looked at the
original library referenced by Pit Captain but didn't find the
extended one). Whether it's useful ... Currently I'm rather interested
in if it's possible.