Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

StringScanner#get_byte

get_byte

Scans one byte and returns it. This method is not multibyte character sensitive. See also: getch.

Example
s = StringScanner.new('ab')
s.get_byte         # => "a"
s.get_byte         # => "b"
s.get_byte         # => nil

s = StringScanner.new("\244\242".force_encoding("euc-jp"))
s.get_byte         # => "\xA4"
s.get_byte         # => "\xA2"
s.get_byte         # => nil
See also #fixed_anchor? #getbyte #exist? #getch also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0