Shuaib Zahda wrote:
> Hi all
>
> in my program I am using a lot of true false conditions. So, I want to
> shorten my code by using the conditional operator ? : but when I use the
> word return it gives an error which i do not really know why?
>
> e.g. x == 5 ? return true : return false
> SyntaxError: compile error
> (irb):19: syntax error, unexpected kTRUE
>
> but if i do not use return it works
>
> x == 5 ? true : false
>
> any idea
>   

That's the format of the ?: operator.

you could do:
z = (x==5)?true: false
return z

Cheers,
Mohit.
11/6/2007 | 6:11 PM.