https://kotlinlang.org logo
#announcements
Title
# announcements
e

evkaky

07/24/2017, 8:05 AM
There is no such thing as a EOF character
really sadly
v

voddan

07/24/2017, 8:06 AM
This one of those "by definition" things
e

evkaky

07/24/2017, 8:15 AM
ok, may you advice me, what should I use instead of unexisting ‘eof’ char? I have such code in Python:
Copy code
def advance(self):
        self.pos += 1
        if self.pos > len(self.text) - 1:
            self.current_char = None  # Indicates end of input
        else:
            self.current_char = self.text[self.pos]
if self.current_char is not None ...
and I’m trying to code something like that but in kotlin. I need some special char value (python programmers have None for that case). May be nullable Char?
v

voddan

07/24/2017, 9:46 AM
A similar API exists in Java. For example
Reader.read()
returns
-1
when the end of file is reached. See https://stackoverflow.com/questions/811851/how-do-i-read-input-character-by-character-in-java
👍 1
You may be able to find better solutions, like reading a file into a stream of characters