Minero Aoki <aamine / loveruby.net> 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