Created
September 29, 2010 23:37
-
-
Save smsohan/603762 to your computer and use it in GitHub Desktop.
This file contains 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
#You have seen something like this, if null replace with a blank array | |
an_array = (another_array || [] ) + (yet_another_array || []) | |
#But you could do this as well | |
an_array = another_array.to_a + yet_another_array.to_a | |
#Or you have seen this | |
an_array = another_array + (an_element_or_array.is_a?(Array) ? an_element_or_array : [an_element] ) | |
#But you could do this | |
an_array = another_array + an_element_or_array.to_a | |
Happy? I am happy! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment