From: David Vallner Date: 2006-12-06T07:10:11+09:00 Subject: Re: Can one use line addresses...to select a portion of file --------------enig50A7BBA81526164A5438B821 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Devin Mullins wrote: > Gregory Seidman wrote: >> inrange =3D false >> lines =3D open(file).read.split("\n").select { |line| >> inrange &&=3D not /__Happy_Meal__/ =3D=3D=3D line >> inrange ||=3D /__McDonalds__/ =3D=3D=3D line >> } > There is a lesser-known (and usually frowned upon?) feature in Ruby tha= t > treats Range notation differently in a "boolean context." >=20 > IO.foreach(file) do |line| # use this rather that loading the whole fil= e > if line =3D~ /__McDonalds__/ .. line =3D~ /__Happy_Meal__/ > do_stuff_with line > end > end >=20 So -this- is what that does? Does this do that? Does anyone know what that notation does? David Vallner Incoherent --------------enig50A7BBA81526164A5438B821 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFFde4/y6MhrS8astoRAkOHAJ4kJSHAYNIlbHwLey3e1F4Dy0EnLwCbB0vG Z93ClQ5mmVHDhp1WQexRwyY= =R9JF -----END PGP SIGNATURE----- --------------enig50A7BBA81526164A5438B821--