On 6/20/05, Nikolai Weibull
<mailing-lists.ruby-talk / rawuncut.elitemail.org> wrote:
> Jason Foreman wrote:
> 
> > Even though it turns out there is no performance benefit to 1 == x
> > over x == 1, I find it desirable to write the former anyway.  If you
> > accidentally write x = 1 instead of x == 1, it can take a long time to
> > figure out your bug.  But if you write 1 = x instead of 1 == x, you
> > get a syntax error, and can immediately correct the mistake.
> 
> % ruby
> if x = 1; end
> -:1: warning: found = in conditional, should be ==
> 
> So please don't write your code as if it was 1980 and you were using a C
> compiler,
>         nikolai
> 

You're right, this type of coding went out of style about the same
time as little code snippet sigs...

> --
> Nikolai Weibull: now available free of charge at http://bitwi.se/!
> Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
> main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}

Oh wait...

;)


All personal attacks aside, Ruby does not issue warnings for this type
of error in all cases (pun intended, see my last message for example)

I happen to like to write my code a certain way, but if you don't
prefer it that's fine with me.


Jason