From: Paul Duncan Date: 2003-09-30T02:53:44+09:00 Subject: Re: Dir.foreach not with patterns? --TN8pJM9vJMHHFgJc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Gavin Sinclair (gsinclair@soyabean.com.au) wrote: > On Wednesday, September 24, 2003, 12:33:54 AM, Alan wrote: >=20 > > ts wrote: > >> next if f =3D=3D "." or f =3D=3D ".." >=20 > > I did used to do that. I can't even remember why I changed it to a reg= exp! >=20 > Come on, you can't resist. >=20 > class Object > def in?(enum) > enum.include?(self) > end > end >=20 > ... > next if f.in? [".", ".."] > ... or next if %w{. ..}.include? f but personally i prefer this: next if f =3D~ /^\.\.?$/ > Isn't that much nicer? ;) > =20 > Gavin >=20 --=20 Paul Duncan pabs in #gah (OPN IRC) http://www.pablotron.org/ OpenPGP Key ID: 0x82C29562 --TN8pJM9vJMHHFgJc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/eHGkzdlT34LClWIRAnFHAKCxLkNaqu4WcOdYd64j8v2FdX/CfgCgxVgP BPrO3S7ZwUsVTK1nLL1EUpM= =Isbc -----END PGP SIGNATURE----- --TN8pJM9vJMHHFgJc--