From: Louis J Scoras Date: 2006-05-03T09:42:03+09:00 Subject: Re: "classes are always open" for anonymous classes? ------=_Part_36725_30114393.1146616920540 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 5/2/06, Joshua Haberman wrote: > > > SyntaxError: compile error > (irb):2: class/module name must be CONSTANT > from (irb):5 > from :0 Yep. The irb error message is actually giving a pretty good hint here. Classes defined with the class keyword are always constants because they start with an uppercase letter. I suppose class_eval is the equivalent? > > x.class_eval { > def foo > end > } > > my_x =3D x.new > my_x.foo Right again. You can also use that or you can assign to a constant: X =3D x class X def foo puts 'bar' end end y =3D x.new y.bar Although, in that case, you might as well assign to the constant in the first place; although, if you continue down that road, there's really no point in declaring it anonymously. -- Lou ------=_Part_36725_30114393.1146616920540--