From: "Hal E. Fulton" Date: 2000-10-11T11:37:25+09:00 Subject: [ruby-talk:5404] Object.foo, setters and so on This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C03302.69442A40 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable OK, here is what I think I know. These three fragements differ only in that the last one defines a private method, no? class Object def foo ... end end def foo ... end def Object.foo ... end And isn't it true that a method like bar=3D must be called with a = receiver? Then why won't this work? def bar=3D ... end self.bar =3D 5 It tells me that bar is private. Why? What is my fundamental = misunderstanding? Hal ------=_NextPart_000_0005_01C03302.69442A40 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
OK, here is what I think I know.
 
These three fragements differ only in that the last one = defines=20 a
private method, no?
 
class Object
  def foo
    ...
  end
end
 
def foo
  ...
end
 
def Object.foo
  ...
end
 
And isn't it true that a method like bar=3D must be called with a=20 receiver?
Then why won't this work?
 
def bar=3D
  ...
end
 
self.bar =3D 5
 
It tells me that bar is private. Why? What is my fundamental=20 misunderstanding?
 
Hal
 
 
------=_NextPart_000_0005_01C03302.69442A40--