You might enjoy the "short-circuiting" operators instead:

condition && ifitstruedothis()
or
condition || ifitsfalsedothis()

these are like C.  Cheers, -r.

On 10/6/07, Greg Willits <lists / gregwillits.ws> wrote:
> > The ternary operator is not used very often, Ruby offers a different
> > way to do what you try.
> >
> > do_stuff if test
> > do_stuff unless test
>
> Ah, OK. Strange structure. (rhetorical Q:) Why read through all the
> do_stuff if it isn't going to matter by the time you get the IF?
>
> I guess I'll switch to that if it is more customary.
>
> > You cannot omit the third parameter from the ternary (that's why it
> > has this name, after all)
>
> OK, thanks for confirming that. Sure, name makes sense, but so does
> allowing a form w/o the ELSE (which is what I am accustomed to doing).
>
> > So if you want to make it work you have to:
> > test ? do_stuff : nil
>
> Tried that early on and still got errors, but after experimenting more I
> see now its beacuse I only tried that in a few places rather than in all
> ternaries in the script. Once I did it for all, the script worked.
>
> > Hope this helps
>
> Indeed. Thanks much.
>
> -- gw
> --
> Posted via http://www.ruby-forum.com/.
>
>


-- 
"We can try to do it by breaking free of the mental prison of
separation and exclusion and see the world in its interconnectedness
and non-separability, allowing new alternatives to emerge." -- after
Vandana Shiva