From: Kyle Rawlins Date: 2002-06-12T01:29:24+09:00 Subject: Re: Composite classes - how to? --k+w/mQv8wyuph6w0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 11, 2002 at 11:06:34PM +0900, Serg Koren wrote: > Class X > def myX > End > End >=20 > Class Y > myNest =3D X::new > =20 > def myY > end > end >=20 > myObject =3D Y::new >=20 > myObject::myNest.myX # <------ gives an error >=20 > What's the proper way of doing this in Ruby? =20 myNest in your code isn't visable externally to the area of the class (it i= s I guess a local variable). If you want it to be a constant (in which case it would be visible) capitalize the first character of its name. If you want = it to be an instance variable do this: class Y attr_reader :myNest def initialize() @myNest =3D X.new end end then the call that you have above should work. -kyle --=20 http://mas.cs.umass.edu/~rawlins -- the pieces of the puzzle are waiting the water of the dark boats --k+w/mQv8wyuph6w0 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9BiVhncsSsHSBypARAqitAJ0c1c+MF+TiSR27qNSUJ0uoA8TYyACgm9e1 1PER9NcBqc2gMzBhPPHBxWw= =O6Ad -----END PGP SIGNATURE----- --k+w/mQv8wyuph6w0--