----- Original Message ----- 
From: "MIcha" <mwohlwend / web.de>
Newsgroups: comp.lang.ruby
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Monday, July 01, 2002 5:30 PM
Subject: is this the way it should work? newbie problem...


> that seems not to work: (it' ported from perl to ruby:-)
> 
> x = max_x if --x == 0;
> 
> the variable x is never decremented.
> why?

The problem is that Ruby has no auto(inc|dec)rement
operators, either pre or post forms. (For reasons I'm
too lazy to go into here.)

I think what you've written actually means:

  x = x_max if -(-x) == 0

You *can* say this in Ruby to do what you want:

  x = x_max if (x-=1) == 0


HTH,
Hal Fulton