Project

General

Profile

Actions

Bug #3406

closed

attr_accessor creates a private writer method

Added by vjoel (Joel VanderWerf) almost 14 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2dev (2010-05-31) [x86_64-linux]
Backport:
[ruby-core:30638]

Description

=begin
(Also, there is a warning that may be incorrect.)

$ cat t.rb
module M
private
def attr_accessor(*args); super; end
end

class C
extend M
attr_accessor :x
end

C.new.x = 1

$ ruby19 -v t.rb
ruby 1.9.2dev (2010-05-31) [x86_64-linux]
t.rb:3: warning: private attribute?
t.rb:11:in <main>': private method x=' called for #<C:0x000000012e5670> (NoMethodError)
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0