|
Re: ambiguity between local variable assignment and writter method: msg#01143lang.ruby.general
[On calling setter from inside the class] Consider this: class HalfDouble attr_reader :double, :half def double=(val) @double = val @half = @double / 2 end def half=(val) @half = val @double = @half / 2 end end hd = HalfDouble.new hd.double = 4 p hd.half p hd.double Then try to replace @double= with self.double= and @half= with self.half= and see what happens... Maybe I'm just being naive, but even though a one uses tongue to translate his thought for the outside world, and ears to translate what comes from the outside world into thought, I see nothing wrong in using just thought for internal communication. In other words, to me, using setters from inside the class seems a lot like talking to oneself. :-) Massimiliano
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: ruby-dev summary 17875-17964, Mauricio Fernández |
|---|---|
| Next by Date: | Re: Choosing ruby?, George Ogata |
| Previous by Thread: | Re: ambiguity between local variable assignment and writter method, Kent Dahl |
| Next by Thread: | Re: ambiguity between local variable assignment and writter method, Gavin Sinclair |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |