From: Eric Hodel Date: 2002-10-15T02:22:03+09:00 Subject: Re: Delegating each --DMLl6fZPX8o7hGmc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Michael Schuerig (schuerig@acm.org) wrote: >=20 > I have a class that basically encapsulates an array and mixes=20 > Enumerable in. Currently it looks something like this >=20 > class C > include Enumerable > ... > def each(&proc) > @myarray.each do |e| > proc.call(e) > end > end > end >=20 > Is there a more direct way of implementing each? Is is possible to get=20 > rid of the each-loop and delegate its behavior to myarray? Or, if you expose a bunch of the array's functionality, class C # ... def method_missing(method_name, *args) @myarray.send(method_name, *args) end # ... end --=20 Eric Hodel - drbrain@segment7.net - http://segment7.net All messages signed with fingerprint: FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 --DMLl6fZPX8o7hGmc Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD) iD8DBQE9qv04MypVHHlsnwQRAiLMAJ43CqaqtT8vdYqthpueBXJ+W0Zy0wCePXcr rWc0CmIfQUR9AcXchJxPYgg= =Efc+ -----END PGP SIGNATURE----- --DMLl6fZPX8o7hGmc--