Created
June 5, 2016 12:28
-
-
Save codesword/8936e147681e5f0187a23262cc8cc223 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Book = "Eloquent Ruby" | |
Module.const_get(:Book) #=> "Eloquent Ruby" | |
Module.const_set(:Book, "Ruby Science") #=> "Ruby Science" | |
Module.const_get(:Book) #=> "Ruby Science" | |
class Person | |
def name | |
"Sword Master" | |
end | |
end | |
person_class = Module.const_get(:Person) #=> Person | |
p = person_class.new | |
p.name #=> "Sword Master" | |
Module.const_set(:Trainer, Class.new { attr_accessor :stack }) | |
trainer_class = Module.const_get(:Trainer) #=> Trainer | |
trainer = trainer_class.new | |
trainer.stack = "Ruby" | |
trainer.stack #=> "Ruby" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment