Getting user input like with Java's Scanner

Lorenzo
Fri, 21 Feb 2020 09:23:09 +0000
New to Julia

Hi guys, this is my first post with a super-newbie question I’d like to ask:
As you may have noticed, I’m new to Julia and I have been coding with Java for a year.
I’d like to get user-input just like in Java but I’m struggling with it.

I’ve tried to use the readline() function: it works great on files, works great on REPL only too, but inside Juno is quite messy
Here is an example inside Juno:

name = readline()
println(name)

This is what I get on console as a result:

julia> asdf


julia> ERROR: UndefVarError: asdf not defined

However, if I do everything on REPL directly, it works fine:

julia> name = readline()
asdf
"asdf"

julia> print(name)
asdf
julia>

What can I do to fix this?
I’m sorry if I got something wrong while writing this post… I do not use blogs very often.
Thanks!

13 posts - 3 participants