From: Niklas Baumstark Date: 2008-08-21T22:34:17+09:00 Subject: Re: class << Array vs. Array.class --Sig_/Y04xXzr3Sb31R.JDL2GwrJA Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hello, "Stefan Lang" wrote: > "class << Array" opens the eigenclass of the Array object. > Thus the foo method is only defined for the Array object itself. >=20 > "Array.class" returns the class of the Array object, which is Class. > Defining a method with module_eval in there means that it > is defined for _all_ class objects. >=20 > To demonstrate this, try to call the methods on another class: >=20 > irb(main):017:0> String.foo > NoMethodError: undefined method `foo' for String:Class > from (irb):17 > irb(main):018:0> String.bar > "inside bar" >=20 > Stefan >=20 thank you! Greetings, Niklas --Sig_/Y04xXzr3Sb31R.JDL2GwrJA Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFIrW+5saTI7fa8xRURAp7BAJ9nkj8L0uYFuzoE4VFsFqnZRcQvXQCfYJGc CGT0p15Zt4ioUKzo5at4eKU= =/TS6 -----END PGP SIGNATURE----- --Sig_/Y04xXzr3Sb31R.JDL2GwrJA--