From: "Gerardo Santana Gómez Garrido" Date: 2008-05-04T02:59:15+09:00 Subject: Re: Why there is not "replace" method for Fixnum? On Sat, May 3, 2008 at 12:39 PM, Iñaki Baz Castillo wrote: > Hi, using String#replace I can "simulate" a pointer (thanks to David A. for > the explanation): > > a = "orignal a value" > b = a > b = "new value" > a > => "original a value" > b > => "new value" > > This is obvious: after the new assigment of "b" it points to a different > object. > > So I can use "replace": > > a = "orignal a value" > b = a > b.replace "new value" > a > => "new value" > b > => "new value" > > > But Fixnum has not this method "replace", neither Float. Doesn't make sense > any primitive Ruby Class having this "replace" method instead of just one of > them? Strings are mutable. Neither Fixnum or Float are; they are immediates. Which means that you can alter the content of a String object, because it's actually a pointer to data, while a Fixnum object *is* its content itself. This is done for performance I think. -- Gerardo Santana