Project

General

Profile

Actions

Bug #10060

closed

private attr_accessor and NoMethodError

Added by Anonymous almost 10 years ago. Updated almost 10 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
[ruby-core:63817]

Description

class Bug
  def initialize
    self.n = 1 # ok
  end

  def t1
    self.n = n + 1 # ok
    self.n += 1 # in `t1': private method `n' called for #<Bug:0x000000019ae1a0 @n=2> (NoMethodError)
  end

  def t2
    n # ok
    self.n # in `t2': private method `n' called for #<Bug:0x0000000218a360 @n=1> (NoMethodError)
  end

  private

  attr_accessor :n
end

Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #9907: Abbreviated method assignment with private attr_writer/attr_reader does not work.ClosedActions
Related to Ruby master - Bug #11096: 'private' access control bypassed when ||= is usedClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0