does ruby have anonymous first-class modules?
Klaus Schilling
does ruby have anonymous first-class modules?
Klaus Schilling
"klaus schilling" <510046470588-0001@t-online.de> schrieb im Newsbeitrag
news:16679.889.686384.815361@gargle.gargle.HOWL...
does ruby have anonymous first-class modules?
Klaus Schilling
Do you mean:
m = Module.new
=> #<Module:0x1018a040>
m.name
=> ""
m.class_eval { def foo; puts "bar"; end }
=> nil
o=Object.new
=> #<Object:0x101c8248>
o.foo
NoMethodError: undefined method `foo' for #<Object:0x101c8248>
from (irb):10
o.extend m
=> #<Object:0x101c8248>
o.foo
bar
=> nil
Kind regards
robert
from :0