The method #scan_integer called with base: 16 is supposed to parse hexadecimal integer literals. There is an edge case when "0x" is not followed by any hex character (e.g. 0x.!@#). In this case #scan_integer doesn't match an integer literal and returns nil:
StringScanner.new("0x.!@#").scan_integer(base: 16)
# => nil
But there are might be pretty valid cases when 0 is expected to be returned instead:
StringScanner.new("0xyz").scan_integer(base: 16) # `"xyz"` is a plain text and `0` is expected
Wondering if it makes sense to match "0" and return 0 in the following cases:
"0x<non-hex-char>"
"+0x<non-hex-char>"
"-0x<non-hex-char>"
"0x<end-of-string>"
"+0x<end-of-string>"
"-0x<end-of-string>"