Thanks

Why is "duration" in durationInMinutes (ie in the statement
duration/60.0) not a local variable but "duration"  is a local variable
in durationInMinutes (ie in the statement duration=(value*60).to_i)?

Regards
Elton

Yukihiro Matsumoto wrote:

> Hi,
>
> In message "[ruby-talk:15833] newbie question"
>     on 01/05/28, Elton Li <eli / waite.adelaide.edu.au> writes:
>
> |I thought it should print 60.0 in all three cases.
>
> Let me explain for each three cases:
>
> |@duration = (value*60).to_i
>
> assign 60*60 to an instance variable @duration.
>
> |self.duration = (value*60).to_i?
>
> invoke attribute write duration=(60*60), thus assigning an instance
> variable @duration as a result.
>
> |duration = (value*60).to_i?
>
> assign 60*60 to a LOCAL VARIABLE "duration", thus no effect happen to
> the receiver.
>
> Hope this helps.
>
>                                                         matz.