From: Robert Klemme Date: 2006-10-18T21:40:09+09:00 Subject: Re: Struct (not) accepting attributes On 18.10.2006 14:33, Kero wrote: >> Sum = Struct.new(:bla, :"sum(value)") >> sum = Sum.new(2, 5) > => # >> sum.send(:"sum(value)") > NoMethodError: undefined method `sum(value)' for # >> class X >> attr_accessor :"sum(value)" >> end > NameError: invalid attribute name `sum(value)' >> class Sum >> define_method(:"sum(value)") { "summum!" } >> end > => # >> sum.send(:"sum(value)") > => "summum!" > > Not sure this is an error in ruby (1.8.5) or a misunderstanding from me (about Struct). There is another option: a misunderstanding on your side which attribute names can be used in this situation / generally. As you see your sample class X does not work either. Why don't you just use "sum_value" as attribute name? Kind regards robert