Tuesday, February 26, 2008

ternary




I'm learning to be a fan of the ternary operator.


condition ? if_true : if_false


If "condition" evaluates as true, return "if_true", otherwise, return "if_false".

I never used this in C, it just didn't feel right, but in Ruby on Rails views, it can really simplify things. I'm learning to like it.