Right now, the tagline-code-snippet thing on Codebrawl is if ( ready? && set? ) { fight! };
. While this looks nice, this is not valid Ruby code.
So, I'm looking for something better. It should be Ruby, and it should look cool. If you have an idea, please fork the Gist and add it to the list below. Thanks! :)
ready? && set? && fight!
if ( ready? && set? ) then fight! end
( ready? && set? ) ? fight! : nil
ready! #(raise if not ready)
set! #(raise if not ready)
fight! #(Will only hit fight if both ready? and set? won't raise an error)
This works if the "ready?" and "set?" method raise exception instead of returning false or nil.
That being said, when competition yell out "ready!" and "set!", they aren't really asking. They are stating. Having ? methods is wrong in this regard. It should be ! and they should raise exception.
ergo
def code_brawl
ready!
set!
fight!
end
Looks the best. I have spoken.
That is all //Seivan