Skip to content

Instantly share code, notes, and snippets.

@iNecas
Created December 7, 2010 16:12
Show Gist options
  • Save iNecas/731970 to your computer and use it in GitHub Desktop.
Save iNecas/731970 to your computer and use it in GitHub Desktop.
What happens, when you don't read documentation
# 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