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#concat

concat(str)

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 #clear #empty? #check_until #eos? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0