Created
February 8, 2012 06:39
-
-
Save rwz/1766091 to your computer and use it in GitHub Desktop.
A little rubyquiz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_object.bool_method?? 'yes' : 'no' | |
# or | |
my_object.bool_method? ? 'yes' : 'no' | |
# or | |
(my_object.bool_method?) ? 'yes' : 'no' |
+1 for second version because it's much more clear for me as for ruby novice.
(my_object.bool_method?) ? : 'yes' : 'no'
@spinogrizz, ok, should add that too, i guess.
much more clean and compact
removing ONE whitespace is "much more compact" now? like, really?
@n1313, yeah, looks better and stuff.
second one, double question marks scare me D:
"yes" if object.bool_value else "no"
:-P
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I prefer first syntax cause it's much more clean and compact.