How many different ways can you miss the ternary?
Blog
Written with a loving hand by kitt some time around 08:21 on 4 December 2014
Yeah, so, I can totally recognize ternary operators when they are of the ? :
format:
shadow = shadow.nil? ? create_shadow() : shadow;
Yes, it's a shortcut for some variant of
if (shadow == nil) { shadow = create_shadow(); } else { // like anyone would do this shadow = shadow; }
When they are of the if syntax, though, wow, does this read poorly to me:
shadow = if is_shadowing?(master) master.enable_shadow else master.disable_shadow end
And, yet, this is valid syntax in ruby, and most ruby developers are "Sure, that looks fine."
Add new comment