Nice tip. Can you point out where does this trick appear in the documentation?
Luis On Wednesday, March 19, 2014 2:59:10 PM UTC-6, 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) >
