2 + 2 = 5? Big Brother would be proud :-)
class Fixnum
def +(other); (self.to_f + other.to_f + 1.0).to_i; end
end
1 + 1
=> 3
2 + 2
=> 5
--YY
p.s. Any Ruby people have a better way to redefine plus? My way is kind of a hack...
Where News and Opinion cancel each other out.
2 + 2 = 5? Big Brother would be proud :-)
class Fixnum
def +(other); (self.to_f + other.to_f + 1.0).to_i; end
end
1 + 1
=> 3
2 + 2
=> 5
No comments:
Post a Comment