On Wed, Jun 14, 2006 at 10:52:06 +1000, Matthew Palmer wrote:
> > On Wed, Jun 14, 2006 at 09:11:49 +1000, Matthew Palmer wrote:
> > > > 
> > > >     const int x = remainder > 2 ? 5 : 0;
> > > 
> > > That's not the same thing.
> > 
> > How so?
> 
> You're setting a value for x regardless of whether the conditional is true
> or false, whereas the Ruby code does not modify the variable unless the
> conditional is true.

I don't know Ruby, but the example I replied to looks to me like it sets
the value of x in both cases:

> x = if remainder > 2 then
>         5
>     else
>         0
>     end

There were two examples in James's email though, and I agree that the
second one:

> x = 5 if remainder > 2

can't be done in C without putting the assignment after the condition.


Cheers,

John
-- 
C++ may be the Uzi/Chainsaw cross of programming languages, but you're
still not supposed to point it at your foot.
            -- Alan Bellingham
_______________________________________________
coders mailing list
[email protected]
http://lists.slug.org.au/listinfo/coders

Reply via email to