Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

StringScanner#<<

<<(str)

Alias of #concat

Appends str to the string being scanned. This method does not affect scan pointer.

Example
s = StringScanner.new("Fri Dec 12 1975 14:39")
s.scan(/Fri /)
s << " +1000 GMT"
s.string            # -> "Fri Dec 12 1975 14:39 +1000 GMT"
s.scan(/Dec/)       # -> "Dec"
See also #concat .new #[] .must_C_version also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0