Consider this syntax error:
julia> S1 = [(.01 : .1 : 1.0);];
julia> S2 = [(.01 : .1 : 1.0);];
julia> [s1 +s2 for s1 in S1, s2 in S2]
ERROR: syntax: invalid comprehension syntax
Stacktrace:
[1] top-level scope
@ none:1
julia> [s1 + s2 for s1 in S1, s2 in S2]
10×10 Matrix{Float64}:
0.02 0.12 0.22 0.32 0.42 0.52 0.62 0.72 0.82 0.92
0.12 0.22 0.32 0.42 0.52 0.62 0.72 0.82 0.92 1.02
0.22 0.32 0.42 0.52 0.62 0.72 0.82 0.92 1.02 1.12
⋮ ⋮
0.72 0.82 0.92 1.02 1.12 1.22 1.32 1.42 1.52 1.62
0.82 0.92 1.02 1.12 1.22 1.32 1.42 1.52 1.62 1.72
0.92 1.02 1.12 1.22 1.32 1.42 1.52 1.62 1.72 1.82
It turns out adding a space between +
and s2
resolves the error.
Is there a way for Julia to guide the user to add a space between +
and a variable etc?
PS: I’ve made this error a bunch of times…