From: ahoward Date: 2003-02-12T23:23:05+09:00 Subject: Re: Range#length?!?!? On Wed, 12 Feb 2003, Martin DeMello wrote: > ahoward wrote: > > > > it also seems to make perfect sense for Float Ranges to have size Infinity? > > this would suprise no one. > > It'd surprise the heck out of me. When I've used float ranges, it's > usually been for Range#include?, and as a convenient way to carry the > two endpoints of a segment around. I'd definitely expect size to return > last-first. i can see your point. however 'last - first' is really the distance between the endpoints, not the range's 'size'. i would consider length or distance to be better method names for 'last - first'. looking at dictionary.com i found size : 1.The physical dimensions, proportions, magnitude, or extent of an object ... Syn: Dimension; bigness; largeness; greatness; magnitude. and in any set theory book i've seen dimension ( [0.0, 42.0) ) or bigness ( [0.0, 42.0) ) or magnitute ( [0.0, 42.0) ) or would all imply infinity. in the case of Fixnum's the 'size' and 'length' of an interval. from the picaxe .... A Range represents an interval---a set of values with a start and an end. .... Ranges can be constructed using objects of any type, as long as the objects can be compared using their <=> operator and they support the succ method to return the next object in sequence. .... so a Range HAS a start and end, but it IS a SET. all that is required to be a set is to implement <=> and succ, which Floats do. using your logic what would be the size of (0.0 .. 42.0) 42.0 right how about this then (0.0 ... 42.0) surely it should be 'just a little' bigger than (0.0 .. 42.0).size right? this is why i say it makes sense to be able to access first and last but suggest that size -> Infinity is much more inline with the semantics of what a set of floats in the real world is. > What's iffy is #each for float ranges. That one is IMO 'surprising' no > matter what it does. completely agree for the same reasons. -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================