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