Project

General

Profile

Feature #19450

Updated by ioquatix (Samuel Williams) almost 2 years ago

This is the best I could come up with: 

 ```ruby 
 klass = Class.new 

 Object.const_set("Klass", klass) 
 Object.send(:remove_const, "Klass") 

 puts klass.new 
 # => #<Klass:0x0000000100a9d688> 
 ``` 

 Can we do better? 

 What about something like: 

 ``` 
 Class.new(name: "Klass") 
 ``` 

 or 

 ``` 
 Class.new do 
   def self.name 
     "Klass" 
   end 
 end 
 ``` 

 etc

Back