Robert Klemme
5/20/2008 8:52:00 AM
2008/5/20 Fredrik <fredjoha@gmail.com>:
> I see... I understand that it is not following the rule of "converting
> the receiver to a float", but I would say that it follows the
> "principle of least surprise".
That may be true for you, but it is not for me - and apparently others as well.
> Of course it is not possible to convert an Array to a Float in any
> meaningful way, so to convert each element into a Float is the
> behaviour I am expecting.
Well, Array#to_f could be defined like this:
class Array
alias :to_i :size
def to_f; to_i.to_f end
end
This is much more meaningful to me than making to_f a conversion of
each element to float. Note, I do not advocate this at all - all I am
saying is that there are more meaningful implementations of to_f than
the one you propose.
> Well... that's my thinking anyway.
Exactly. :-)
Kind regards
robert
--
use.inject do |as, often| as.you_can - without end