Project

General

Profile

Actions

Bug #4537

closed

Incorrectly creating private method via attr_accessor

Added by ryanlecompte (Ryan LeCompte) over 13 years ago. Updated over 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
[ruby-core:<unknown>]

Description

The following fails with a failure to call "x=" private method

String.send(:attr_accessor, :x)
s = ""
s.x = 100

The following works:

class String
  self.send(:attr_accessor, :x)
end
s = ""
s.x = 100

Files

attr-visibility-4537.patch (2.75 KB) attr-visibility-4537.patch jeremyevans0 (Jeremy Evans), 08/01/2019 12:08 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0