"Florian Gross" <flgr / ccan.de> schrieb im Newsbeitrag news:34fjg2F48l5qgU1 / individual.net... > Robert Klemme wrote: > > > Totally agree! And it doesn't make a difference from the usage point of > > view since instances of Symbol, Fixnum, TrueClass, FalseClass, NilClass > > are immutable. > > Note that there is a small difference for Symbols and Fixnums. You can > not define singleton methods on those objects. Yep. > Maybe external singleton > classes that work like exivars would help with that. Uh, oh... What's an "exivar"? > > Addenum: it's especially noteworthy that strings literals are treated > > differently from true, false, Fixnums and Symbols. They create a new > > string instance on each evaluation. > > But note that literals with the same content will actually share the > String buffer. True (yet another optimization). But only as long as they are not modified. It's about the same behavior as #dup was called on some string held behind the scenes. Still another object instance has to be allocated which is why in performance critical parts you're usually better off defining a frozen string constant if the string doesn't change anyway. class Dummy SAMPLE = "foo".freeze def call_often(str) str.include? SAMPLE end end Kind regards robert