V
VÃt Ondruch
Hello everybody,
I would like to have locally monkeypatched Hash in my module. I would
expect that following example will work, however it doesn't. How to do
it correctly?
irb(main):016:0> module Foo
irb(main):017:1> class Hash << ::Hash
irb(main):018:2> def bar
irb(main):019:3> puts 'bar'
irb(main):020:3> end
irb(main):021:2> end
irb(main):022:1> end
SyntaxError: (irb):17: syntax error, unexpected tLSHFT, expecting '<' or
';' or '\n'
class Hash << ::Hash
^
from c:/Ruby/bin/irb:12:in `<main>'
Cheers,
Vit
I would like to have locally monkeypatched Hash in my module. I would
expect that following example will work, however it doesn't. How to do
it correctly?
irb(main):016:0> module Foo
irb(main):017:1> class Hash << ::Hash
irb(main):018:2> def bar
irb(main):019:3> puts 'bar'
irb(main):020:3> end
irb(main):021:2> end
irb(main):022:1> end
SyntaxError: (irb):17: syntax error, unexpected tLSHFT, expecting '<' or
';' or '\n'
class Hash << ::Hash
^
from c:/Ruby/bin/irb:12:in `<main>'
Cheers,
Vit