core :: Reader :: read_nonwhitespace
Returns the code point of the character.
Returns null
on end of file or error.
In fact, this method works like read_char
except it skips whitespace.
var w = new StringReader(" \nab\tc")
assert w.read_nonwhitespace == 'a'
assert w.read_nonwhitespace == 'b'
assert w.read_nonwhitespace == 'c'
assert w.read_nonwhitespace == null
Char::is_whitespace
determines what is a whitespace.
# Skip whitespace characters (if any) then return the following non-whitespace character.
#
# Returns the code point of the character.
# Returns `null` on end of file or error.
#
# In fact, this method works like `read_char` except it skips whitespace.
#
# ~~~
# var w = new StringReader(" \nab\tc")
# assert w.read_nonwhitespace == 'a'
# assert w.read_nonwhitespace == 'b'
# assert w.read_nonwhitespace == 'c'
# assert w.read_nonwhitespace == null
# ~~~
#
# `Char::is_whitespace` determines what is a whitespace.
fun read_nonwhitespace: nullable Char
do
var c: nullable Char = null
while not eof do
c = read_char
if c == null or not c.is_whitespace then break
end
return c
end
lib/core/stream.nit:457,2--481,4