J
Joey Zhou
Here is a sample code:
str = "ABC"
class << str
p self
end
What I get is somthing like "#<Class:#<String:0x15d4bb0>>".
If "p str", there's an error message:
x.rb:3:in `singletonclass': undefined local variable or method `str' for
#<Class:#<String:0x1625bf8>> (NameError)
How can I get the value of str("ABC") within the class << str;...;end
block?
Thank you.
Joey
str = "ABC"
class << str
p self
end
What I get is somthing like "#<Class:#<String:0x15d4bb0>>".
If "p str", there's an error message:
x.rb:3:in `singletonclass': undefined local variable or method `str' for
#<Class:#<String:0x1625bf8>> (NameError)
How can I get the value of str("ABC") within the class << str;...;end
block?
Thank you.
Joey