Skip to content

Instantly share code, notes, and snippets.

@jeffkreeftmeijer
Created July 3, 2011 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jeffkreeftmeijer/1062136 to your computer and use it in GitHub Desktop.
Save jeffkreeftmeijer/1062136 to your computer and use it in GitHub Desktop.
Finding something like `if ( ready? && set? ) { fight! };` in Ruby

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
fight! if ready? && set?
@spllr
Copy link

spllr commented Jul 3, 2011

fight! if ready? and set?

@jeffkreeftmeijer
Copy link
Author

@spllr that's a good one I've been thinking about, but the order bugs me a bit. I'd love it to sound like "ready? set? fight!". :)

@spllr
Copy link

spllr commented Jul 3, 2011 via email

@spllr
Copy link

spllr commented Jul 3, 2011

Not a pretty but valid:

while (ready? and set?) do; fight! end

@gcapizzi
Copy link

gcapizzi commented Jul 3, 2011

I think
if ready? && set? then fight! end
is the most readable solution.

@raul
Copy link

raul commented Jul 3, 2011

if (ready? && set?); fight!; end or if ready? && set?; fight!; end preserve the intended order - I dislike the semicolons though

@jeffkreeftmeijer
Copy link
Author

Thanks everyone, I went for if ready? && set? then fight! end: http://codebrawl.com :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment