Having trouble with the parse function

Hey all,

I´m trying to make a very simple code where the user types a radius and julia returns the calculated area and circumference of a circle with that radius.

println(“circle.jl”); println(“Escolha um raio”); raio = readline(); parse(Int64, raio); print(2*π*raio); print(2*π*raio)

However, it says there is a Method Error; no method matching. What is the problem here?
Also, i´d love suggestions of better/simpler ways to write the code if you have any. Thanks in advance.

Parse does not mutate the variable passed into it. Instead, it returns the parsed output. You can tell this because it does not have an exclamation point at it’s end: push!(vec::Vector, var) modifies vec, but parse does not.

So the real error is raio staying as a String. Then when you try to multiply it by 2π, the compiler errors, because Int64*String is not defined.

If you save the output of parse to a variable, this should work:

println("circle.jl")
println("Escolha um raio")
raio = readline()
parsed_raio = parse(Int64, raio)
print(2*π*parsed_raio)
print(2*π*parsed_raio)

P.S.
You can use ` or ``` to make your code more readable and copyable!

Thank you soo much for the help!