From: Guillaume Marcais Date: 2006-07-08T11:22:37+09:00 Subject: Re: Float#==. Legacy? Le 7 juil. 06, � 15:30, Joel VanderWerf a �crit : > > The Float#=~ that Martin suggested is nice, but it still doesn't help > with one of the problems which (I think) the OP wanted: > > x = 1.2 > y = 1.2000000000000001 > p(x =~ y) # => true > p([x] =~ [y]) # => false > Yes, this is what I was referring to. I came about a little differently. Mainly that calling Float#within_delta or equivalent is easy when I have the float itself, but if is embedded in an Array or Hash, it renders #== useless on the structure: [1+1, 3] == [2, 3] # => true [0.1+0.2, 3] == [0.3, 3] # => false For the second case, one would needs to loop on the elements of the array. And my second realization is if Float#== is (almost) always a mistake, why not change it to something useful most of the time. Changing Float#== in my code the way I did make me a little nervous as it is changing a pretty fundamental behavior, but on the other hand it is hardly ever used and it made sense in my case. Guillaume.