From: ahoward Date: 2003-02-04T04:54:50+09:00 Subject: Re: ruby-dev summary 19437-19455 On Tue, 4 Feb 2003, Matt Armstrong wrote: > Minero Aoki writes: > > > ARGF.each do |line| > > print line if line.index(once 'PATTERN') > > end > > > > Matz considers that the better plan is to make string literal create > > an object only once. > > So long as the string is duped when modified. E.g. > > def mystring > 'hi' > end > > puts mystring.sub!(/h/, 'H') > => Hi > puts mystring > => hi clearer to def mystring static 'hi' end puts mystring.sub!(/h/, 'H') # -> Hi puts mystring # -> Hi VS def mystring 'hi' end puts mystring.sub!(/h/, 'H') # -> Hi puts mystring # -> hi this applies to more than only String objects. -a -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ahoward@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================