I have a .jl file with one line script:
i = read(stdin, Char)
If I run it, and type ab
in the REPL (without pressing the return key), I get:
a'b': ASCII/Unicode U+0062 (category Ll: Letter, lowercase)
julia> i
'b': ASCII/Unicode U+0062 (category Ll: Letter, lowercase)
i
takes the second character entered (b
).
Here is the behavior in REPL (need to press the return key after typing ab
)
julia> i = read(stdin, Char)
ab
'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)
julia> b
ERROR: UndefVarError: `b` not defined
julia> i
'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)
i
takes the first character entered (a
).
So read
is reading different values depending on whether it is run in a script vs in REPL, and it sometimes requires pressing the return key while other times it doesn’t.
How do I make sense of this?