Created
September 18, 2010 09:27
-
-
Save wpiekutowski/585526 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
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