Created
June 20, 2018 19:31
-
-
Save tushartuteja/e993d801c3311628dd084e65826f1258 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 | |
puts "at the starting of person class" | |
def self.my_attr_reader variable_name | |
evaluate_string = "def #{variable_name} \n" + | |
"return @#{variable_name} \n" + | |
"end \n" | |
eval(evaluate_string) | |
end | |
my_attr_reader "name" | |
def initialize name, age | |
@name = name | |
@age = age | |
end | |
puts "at the end of person class" | |
end | |
person = Person.new("Tushar", 27) | |
puts(person.name) | |
###### Look Here ######## | |
Person.my_attr_reader "age" | |
puts (person.age) | |
###### Code in discussion Ends ########## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment