From: David Vallner Date: 2006-04-11T10:38:57+09:00 Subject: Re: Class Definition inside a method definition? --nextPart33675704.i0Ih0tRTqT Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline D=C5=88a Utorok 11. Apr=C3=ADl 2006 02:39 Bihal nap=C3=ADsal: > Thanks David. I'm not sure you caught sight of the line of code I was > worried about. I should have made it more clear. This one in particular > > sclass =3D class << self; self; end > > does use a class keyword and syntactic construct, it's just on a single > line. > > Bihal Well, "class << self" isn't really a class definition, it's a change of sco= pe=20 into an object's singleton class. It just looks a real awful lot like one ;= P=20 Which might, or might not exist at the time, and in the latter case it=20 indeeds starts to exist. I'm also possibly very wrong, but I've been able t= o=20 live with understanding this that way ;P Also, Pickaxe seems mildly wrong about the instance method definition bit: irb(main):001:0> class Foo irb(main):002:1> def bar irb(main):003:2> def quux irb(main):004:3> puts "Foo#quux" irb(main):005:3> end irb(main):006:2> end irb(main):007:1> end =3D> nil irb(main):008:0> foo =3D Foo.new =3D> # irb(main):009:0> foo.quux NoMethodError: undefined method `quux' for # from (irb):9 from :0 irb(main):010:0> foo.bar =3D> nil irb(main):011:0> foo.quux =46oo#quux =3D> nil irb(main):012:0> Foo.new.quux =46oo#quux =3D> nil Is that 1st ed. or 2nd ed. you're quoting? Might have changed between Ruby = 1.6=20 and 1.8. David Vallner --nextPart33675704.i0Ih0tRTqT Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQBEOwim+aUhotvmpDgRAtxLAJ9BgYgmdrt/l4XlcwpkANogM5i4vgCfeK5K ifF+HxR/ZsIHUya6jFzymAI= =mFpc -----END PGP SIGNATURE----- --nextPart33675704.i0Ih0tRTqT--