Ternary operator ?: confused with quoting

Hi I am doing the pi exercise in JuliaBox and would like to know how I could use the ternary operator ( a ? b : c ) correctly. Any suggestions?

function calculate_pi(N,r)
Acircle = 0
Asquare = 0

for x in 1:N    
    x,y = rand([-1:1]), rand([-1:1])

    dist = sqrt(x^2 + y^2)

    dist < r ? Acircle++ : Asquare++
end
return 4*(Acircle/Asquare)

end

N = 1000
r = 1
calculate_pi(N, r)

ERROR
syntax: space not allowed after “:” used for quoting

Afaict, (didn’t check) this is because ++ is a binary operator so the parsing continues to consume : and what’s after it as the second operand of ++

1 Like

thank you!