Created
December 7, 2010 16:12
-
-
Save iNecas/731970 to your computer and use it in GitHub Desktop.
What happens, when you don't read documentation
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
# getting first item of array or empty hash, when empty: | |
# A) Without documentation: | |
def get_first_item_from_array(array) | |
unless array.blank? | |
array.each do |single| | |
return single | |
end | |
end | |
return {} | |
end | |
# B) With documentation: | |
array.first || {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment