[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: Why nil
From: Robert Klemme <shortcutter () googlemail ! com>
Date: 2018-07-09 14:30:51
Message-ID: CAM9pMnOC9gtxjEwH8OKJ1jx1nLKxxzG51C1f-v4Z=FXGuoHAaw () mail ! gmail ! com
[Download RAW message or body]
On Sun, Jul 8, 2018 at 2:14 PM Wolf <wolf@wolfsden.cz> wrote:
>
> On , Andy Jones wrote:
> > >>>>>>>>
> > The problem is that setter/getter can become more complicated
> > than just assigning or getting value.
> >
> > If your code uses getter/setter more than 1 time you should not use
> > instance variable directly.
> >
> > In the end, using it directly has no benefits at all if you know ruby.
> > Well, except for absence of one code line `attr_accessor :a`.
> > <<<<
> >
> > But as already noted, you are forced to use @var = 1 and not var = 1 inside the class.
>
> Why are you forced to do that?
Because it's the way the language is built.
> You can just use `self.var = 1`.
You can, but then you need a method "var=" and the state needs to be
stored somewhere, presumably in an instance variable @var.
Cheers
robert
--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
- without end}
http://blog.rubybestpractices.com/
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic