[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Why nil
From:       Dmitriy Non <non.dmitriy () gmail ! com>
Date:       2018-07-04 19:04:24
Message-ID: 1DEC16A4-B015-48FD-AC88-6FDD93564261 () gmail ! com
[Download RAW message or body]

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`.
--------------------------------------
Dmitriy Non
non.dmitriy@gmail.com



On 4 Jul 2018, at 16:02, Andy Jones <Andy.Jones@jameshall.co.uk> wrote:

> I think that you expected method1 and method2 to call the accessor methods,

This is why I prefer to always use @ to refer to attributes inside their class, \
contrary to what some quite respected Rubyists suggest.


Click here to view Company Information and Confidentiality \
Notice.<http://www.jameshall.co.uk/index.php/small-print/email-disclaimer>

Please note that we have updated our privacy policy in line with new data protection \
regulations. Please refer to our website to view the ways in which we handle your \
data.

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>


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