apologies if this has been discussed before, but i was surprised it didn’t work when i naively tried it:
julia> for i in 1:10 if i>3
ERROR: syntax: incomplete: "for" at REPL:1 requires end
 top-level scope at REPL:0
strange because the
if clause works in comprehensions:
julia> [i for i in 1:10 if i>3]
has there been any discussion on making this possible? why wouldn’t we want them to work similarly?
One way you could do it is with a generator.
foreach( (i for i in 1:10 if i>3) ) do i
Or just (well, mostly) pressing return.
for i in 1:10
You could probably put the logic inside the range like
for i in filter(x -> x > 3,1:10)
(I didn’t test this)
even more straight forward…
for i in 4:10
This syntax already means something:
julia> for i in 1:6 if i > 4
[ Info: 5
[ Info: 6
In other words, you just need to add a second
end to close the
if block. Changing this would be a breaking change to where these blocks end.