I'm getting a ParseError and I dont know why

I’m writing a function and I keep getting this error message:

LoadError: ParseError:
# Error @ ./mixed-juices.jl:52:14
   if length(orders) < 1
#            ┌───────
       time left = 0
   end
#──┘ ── Expected `end`

What am I doing wrong??? I added an ‘end’ where its needed??? New to Julia please help.

Perhaps you forgot an underscore?

This works fine:

julia> if length(orders) < 1
           time_left=0
       end
2 Likes

Ph yeah thanks

For my own edification is this part of the error message:

#            ┌───────
       time left = 0
   end
#──┘ ── Expected `end`

saying “the end at the right end of the square bracket was expected at the left end of that bracket, i.e. after time”?

It’s clearer with colour (and without Discourse text formatting screwing up the alignment a bit) I think:

It’s marking that part of the code as unexpected.

1 Like

Ah right, the bracket doesn’t actually end on the end - makes sense, thanks.