From: Sergey Volkov Date: 2006-05-11T18:23:05+09:00 Subject: Re: Writable attributes - how does this work? Krekna, your understanding is correct: # >> x = Object.new => # >> x.aa = 10 NoMethodError: undefined method `aa=' for # # note method name reported: 'aa=' Sergey ----- Original Message ----- From: "Krekna Mektek" To: "ruby-talk ML" Sent: Thursday, May 11, 2006 5:12 AM Subject: Writable attributes - how does this work? Hi! How does this actually work? from the Pick Axe book: irb> 1> class Song 2 > def duration=(new_duration) 3> @duration = new_duration 4> end 5> end 6> 7> song = Song.new("Bicylops", "Fleck", 260) 8> song.duration --> 260 9> song.duration = 257 10> song.duration --> 257 If a method name which is used to set the attribute is called "duration=", how come that one can use song.duration = 257? I mean, does it just work lik this, because the Ruby engine recognizes the 'set attribute' method just because of the = sign after the "duration" on line number two? Tnx, Krekna