B
Bram Wijnands
I'm stuck on why this occurs. (using jRuby 1.1.5 & Ruby 1.8.6)
I'm trying to use modules to scope certain class overrides, so say the
String class is changed in ModuleA i don't want it to affect ModuleB.
But when i try to accomplish this i run in to two things.
First, when creating a Module and overwriting, just for example, the
reverse method. results in an error:
module ModuleA
class String; def reverse;false;end; end
p String.new("abc").reverse
end
Okay, so it creates its own class String instead of taking the core
class String. Basicly what i want is the module to have it's own set of
core classes.
Secondly, when using direct instantiation in a module it wont use the
overwritten class, example:
module ModuleA
class String < String; def reverse;false;end; end
p String.new("abc").reverse
p "abc".reverse
end
Results in:
false
cba
Instead of false; false
Could anyone point me in the right drection, thanks in advanced !
I'm trying to use modules to scope certain class overrides, so say the
String class is changed in ModuleA i don't want it to affect ModuleB.
But when i try to accomplish this i run in to two things.
First, when creating a Module and overwriting, just for example, the
reverse method. results in an error:
module ModuleA
class String; def reverse;false;end; end
p String.new("abc").reverse
end
Okay, so it creates its own class String instead of taking the core
class String. Basicly what i want is the module to have it's own set of
core classes.
Secondly, when using direct instantiation in a module it wont use the
overwritten class, example:
module ModuleA
class String < String; def reverse;false;end; end
p String.new("abc").reverse
p "abc".reverse
end
Results in:
false
cba
Instead of false; false
Could anyone point me in the right drection, thanks in advanced !