Skip to content

Instantly share code, notes, and snippets.

@wpiekutowski
Created September 18, 2010 09:27
Show Gist options
  • Save wpiekutowski/585526 to your computer and use it in GitHub Desktop.
Save wpiekutowski/585526 to your computer and use it in GitHub Desktop.
class User
attr_accessor :first_name, :last_name
def full_name
"#{@first_name} #{@last_name}"
end
def full_name=(full_name)
@first_name, @last_name = full_name.split(' ')
end
end
user = User.new
user.full_name = "John Doe"
user.first_name #=> "John"
user.last_name #=> "Doe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment