Created
January 1, 2020 01:56
-
-
Save al3rez/3dc26510f5f09f72c6bc631a06e19559 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 Person | |
attr_reader :first_name, :last_name | |
def initialize(first_name, last_name) | |
@first_name, @last_name = first_name, last_name | |
end | |
end | |
class PersonWithFullName < SimpleDelegator | |
def full_name | |
first_name + " " + last_name | |
end | |
end | |
person = Person.new("Alireza", "Bashiri") | |
PersonWithFullName.new(Person).full_name # => Alireza Bashiri | |
person.full_name # => undefined method `full_name' for main:Person (NoMethodError) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment