From: "Iñaki Baz Castillo" Date: 2008-05-04T02:58:56+09:00 Subject: Re: Why there is not "replace" method for Fixnum? El Sábado, 3 de Mayo de 2008, Sebastian Hungerecker escribió: > Iñaki Baz Castillo wrote: > > But Fixnum has not this method "replace", neither Float. > > Consider this: > a = 5 > b = 5 > a.object_id == b.object_id #=> true > > So a and b point to the same object even if there was no "a = b" anywhere. > That is because in ruby there is only one single instance of any integer, > so two variables pointing to 5 always point to the same object. This is > because of performance. As a consequence of this something like 5.replace 6 > would change *all* occurences of 5 to 6 which clearly would not be the > desired behaviour. So there is no Integer#replace. Opss, aewsome! I couldn't imagine it. Thanks a lot for the explanation :) -- Iñaki Baz Castillo