D
Daniel Finnie
Is there such a thing?
If I have the following code:
class Klass
@@var = 0
end
How can I make an attr_writer for it besides doing
class Klass
def var=(other)
@@var = other
end
end
I've tried all of these to no avail:
attr_writer :'Klass.var' # => `attr_writer': invalid attribute name
`Klass.var' (NameError)
attr_writer :'var' # => undefined method `currentRound=' for Team:Class
(NoMethodError) (when I try to use the writer function later)
attr_writer :'self.class.var' # => `attr_writer': invalid attribute name
`self.class.var' (NameError)
Any ideas? I mean it's not a huge deal but I would like to find a way
around making the method described above.
Thanks,
Dan
If I have the following code:
class Klass
@@var = 0
end
How can I make an attr_writer for it besides doing
class Klass
def var=(other)
@@var = other
end
end
I've tried all of these to no avail:
attr_writer :'Klass.var' # => `attr_writer': invalid attribute name
`Klass.var' (NameError)
attr_writer :'var' # => undefined method `currentRound=' for Team:Class
(NoMethodError) (when I try to use the writer function later)
attr_writer :'self.class.var' # => `attr_writer': invalid attribute name
`self.class.var' (NameError)
Any ideas? I mean it's not a huge deal but I would like to find a way
around making the method described above.
Thanks,
Dan