I think the problem was expr1, not expr2: you probably didn't make expr1 
return a Bool. (Julia deliberately does not support "if cond" unless cond is a 
Bool.)

Demo of correct usage:

julia> x = 5
5

julia> x == 4 && "hello"
false

julia> x == 5 && "world"
"world"

Best,
--Tim

On Friday, May 06, 2016 12:12:28 PM Adrian Salceanu wrote:
> The only place where I find the "end" requirement annoying is for one line
> IF statements. When you have a short one liner, the "end" part just does
> not feel right. It would be nice if the "end" could be left out for one
> liners. Even PHP allows one to skip the accolades in such cases.
> 
> If there's some other way of achieving this I'd love to hear about it. I
> don't like the ternary operator in this situation cause it forces me to add
> the 3rd part as "nothing" or whatever. And doing "expr1 && expr2" only
> works when expr2 is "return" for instance, otherwise the compiler complains
> about using a non-boolean in a boolean context.
> 
> vineri, 6 mai 2016, 20:37:49 UTC+2, Stefan Karpinski a scris:
> > There is a long history of languages using this syntax, including Algol,
> > Pascal, Ruby and Matlab.
> > 
> > On Fri, May 6, 2016 at 2:26 PM, Ford Ox <[email protected] <javascript:>>
> > 
> > wrote:
> >> Is there any reasoning behind it? It seems to me like a weird choice
> >> since you have to type three letters, which is the complete opposite of
> >> the
> >> goal of this language - being very productive (a lot work done with
> >> little
> >> code).
> >> On top of that, brain has to read the word every time your eyes look at
> >> it so you spend more time also reading the code - tho this should be easy
> >> to omit, by highlighting this keyword by other color than other keywords
> >> (the current purple color in ATOM just drives me crazy, since it is one
> >> of
> >> the most violent colors, so my eyes always try to read that useless piece
> >> of information first, instead of the important code).

Reply via email to