From: Jingjing Duan Date: 2012-07-06T02:16:50+09:00 Subject: Can you call private methods with explicit receivers? My understanding is the answer is no, you can't call private methods with explicit receivers, even self. See http://www.skorks.com/2010/04/ruby-access-control-are-private-and-protected-methods-only-a-guideline/ However, the following example seems to counter that. class A def m2 self.m1 = "hello" self.m3 end private def m1=(value) @m1 = value puts "assigning #{value} to @m1" end def m3 puts "inside m3" end end A.new.m2 The output is: assigning hello to @m1 /tmp/t.rb:4:in `m2': private method `m3' called for # (NoMethodError) from /tmp/t.rb:19:in `
' Why can m2 call self.m1= which is a private method? $ ruby –v ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0] Best, Jingjing -- Posted via http://www.ruby-forum.com/.