Question : Conditional Operator

Hi, is there a conditional operator in Ruby like the ? in C/C#, ie

x = y == nil ? 0 : 1

I know you can do

x = if (y == nil) then 0 else 1 end

Just wondering if the more compact is possible in Ruby.  

Thanks!

Answer : Conditional Operator

you can use the ? in ruby as in C

x = y == nil ? 0 : 1

will work
Random Solutions  
 
programming4us programming4us