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) >
