Is there a built-in way to read stdin as a stream?...
# getting-started
l
Is there a built-in way to read stdin as a stream? Something like Node's
process.stdin
?
n
well, there's System.
in
the global
readLine()
might also be useful
l
I did this with
readLine()
but that's kinda bad:
Copy code
fun stdin(): Flow<String?> = flow { // flow builder
    while (true) {
        var x = readLine();
        emit(x);
    }
}
testing out System.
in
Need to look at that syntax though
n
I don't know about flows, but you at least want
readLine() ?: break
...and no semicolons 😛