Apologies for the newbie question.
I’m not a coder, but trying to get a little familiar with Julia. I’ve installed it on my MacBook, along with Juno and Atom.
From what I’ve been able to find, I should be able to get input from the user with “read” or “readline” or “input”. (At first, I found a google hit that showed me an “input” that I think is a user-defined function, but then later I found “input()” mentioned in the Julia/Juno in-Atom documentation.)
But my short test code-snippet is not behaving as I would expect. Here’s my code:
print("Enter your name: ")
n = readline()
println(“Your name is $n.”) # Just to test if one of these two methods behaves differently.
println("Your name is ", n, “.”) # They behave the same.
When I run my code, I’m prompted in the REPL to enter my name. I click in the REPL to give that window the focus, and then type in a name (say, Kent).
When I hit ENTER, the prompt disappears Why? I didn’t tell it to disappear.
I see my name on the screen, as I’ve entered it. It sits there forever until I hit ENTER a second time. Why am I having to hit ENTER twice?
When I do that, the REPL then displays a blank line, then my sentences, without my name, then an error, like this:
Your name is .
Your name is .
julia> ERROR: UndefVarError: Kent not defined
I’ve been googling and experimenting for two days, and am no closer to understanding what is going on or how to get user input than when I began.
i try different code:
n = input("Enter your name: ")
println(“Your name is $n.”) # This is a comment
println("Your name is ", n, “.”) # It should be ignored.
I get to the point where I have entered my name, and then the REPL appears to become somewhat catatonic, and about all I can get to work is a Ctrl-C stopping of Julia or a Ctrl-C-generated set of error messages (no real consistency in the result).
Am I doing things wrong? Is Julia not a sufficiently general-purpose programming language to handle such a simple user-input task? Have I uncovered some Mac-based bug? Other?