Skip to content

Instantly share code, notes, and snippets.

/.rb

Created October 6, 2015 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/bc0f756e26f1762beab3 to your computer and use it in GitHub Desktop.
Save anonymous/bc0f756e26f1762beab3 to your computer and use it in GitHub Desktop.
which code is better ?
# Survey:
# which of the following two equivalent peices of code do you find most pleasing to the eye ?
#
range = offset == 0 ? (0..23) : (offset > 0 ? (offset..23) : (0..(23-offset)))
#
# Or
#
range = case offset
when > 0
(offset..23)
when < 0
(0..(23 - offset))
else
(0..23)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment