On Wed, Jun 25, 2014, Ryan Davis wrote:
> 
> On Jun 25, 2014, at 4:44, Wayne Conrad <kf7qga / gmail.com> wrote:
> 
> > On 06/23/2014 04:30 AM, Sylvain Joyeux wrote:
> >> 
> >> How many people actually *do* use -w ? Is this really a "best practice" in the ruby world these days ?
> >> 
> > I do not attempt to write "-w clean" code, or even use `-w`, because:
> > 
> >    wayne@mercury:~$ irb -w
> >    2.1.1 :001 > class Foo
> >    2.1.1 :002?>   private
> >    2.1.1 :003?>   attr_accessor :bar
> >    2.1.1 :004?>   end
> >    (irb):3: warning: private attribute?
> > 
> > There is occasionally a valid reason to make a private accessor/reader/writer, and no harm that I know of.
> 
> Not true. You can't call a private writer (without send) because private means you can't use a receiver.
> 
> 

Hmm; that doesn't seem to be the case at least in 2.1.1:

    class Foo
      private
      attr_accessor :bar

      public
      def set_bar(b)
        self.bar = b
      end

      def get_bar
        bar
      end
    end

    f = Foo.new
    f.set_bar(42) # no warning except under -w
    puts f.get_bar # outputs 42

Perhaps I misunderstand you, and you meant that using self as a receiver
for a private method merely triggers a warning under -w.