From: Konrad Meyer Date: 2007-11-19T11:38:44+09:00 Subject: Re: Open-ended ranges? --nextPart1438908.PrTloJtYPt Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Quoth Todd Benson: > On Nov 18, 2007 8:10 PM, Konrad Meyer wrote: >=20 > > > > irb(main):001:0> 0..(1.0/0) > > =3D> 0..Infinity > > > > HTH, > > > > -- > > Konrad Meyer http://konrad.sobertillnoon.com/ >=20 > Right, >=20 > (0..(1.0/0)).each { |o| puts "my_range includes " << o.to_s } >=20 > It's not indeterminate, it's a definite infinity (within the > computers' capabilities, of course). There's a difference. I suppose > if you use a check within the loop, that might help the use case, but > it still screams of language infidelity. >=20 > Of course, I'm just assuming the OP wants 1 to some undetermined > number as an object (a duck) that will quack yes at being asked if > it's a Range. >=20 > I'm still trying to figure out why you would want a Range object -- > which, by usual definition -- is a _not_ open-ended, have an infinite > side. >=20 > Todd (0..(1.0/0)).each { } will never complete though, because 0.succ is=20 eventually going to be a Bignum, while 1.0/0 is a float value Infinity. Sin= ce=20 a bignum is always going to be less than Infinity, the block is=20 executed "forever". (Or at least until the bignum runs the machine out of=20 ram.) Regards, =2D-=20 Konrad Meyer http://konrad.sobertillnoon.com/ --nextPart1438908.PrTloJtYPt Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQBHQPc2CHB0oCiR2cwRAiYPAJ93YyXuao6hjmBAlqPZ/UdJgbWzhwCgsF7a ZCSVbzxuyVEebASnroY8IL0= =7dCf -----END PGP SIGNATURE----- --nextPart1438908.PrTloJtYPt--