Skip to content

Instantly share code, notes, and snippets.

@sevenseacat
Last active December 28, 2015 06:58
Show Gist options
  • Save sevenseacat/7460485 to your computer and use it in GitHub Desktop.
Save sevenseacat/7460485 to your computer and use it in GitHub Desktop.
Alternatives for a full_name method
class User
# Downsides - when first name is nil, you'll have a string like " LastName"
def full_name
"#{first_name} #{last_name}"
end
# Downsides - a bit harder to understand
def full_name
[first_name, last_name].compact.join(' ')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment