I would urge you to always put a semicolon after the condition; you'd be surprised at how often part of the consequent is parsed as part of the condition otherwise! It's quite brittle. In fact, I think that semicolon or newline should be required after the if condition for this reason.
It's not bad to put a semicolon before the end as well, but I don't know that leaving it out has the same potential to cause trouble. On Thursday, 20 March 2014 10:24:16 UTC+1, Cristóvão Duarte Sousa wrote: > > Hum, ok. > > Although the short-circuit is more or less known among several programming > languages, I don't think it's that "readable" outside of an "if". > Maybe after a while one starts to read that code as "if then", but it's > not so straightforward to beginners reading someone else's code. > > But the question is answered: that's the julian way :) > Thanks > > On Wednesday, March 19, 2014 8:59:10 PM UTC, Steven G. Johnson wrote: >> >> On Wednesday, March 19, 2014 11:33:57 AM UTC-4, Cristóvão Duarte Sousa >> wrote: >>> >>> Sometimes I see myself writing one line if-elses like `if x<0 x=-x end`, >>> which I think is not very "readable". >>> >> >> Of course, in this particular case you could just do x = abs(x), but a >> typical style for one-line if-then in Julia is to use &&: >> >> n == 0 && return 0 >> n < 0 && throw(BoundsError()) >> >> or in this case >> >> x < 0 && (x = -x) >> >