jeudi 6 avril 2017

How to define a dynamic constant in ruby? [duplicate]

This question already has an answer here:

I'm trying to recreate a case_class (like from Scala) but in ruby. so I've tried def case_class name Object.const_set name, Class.new {} end but I get NameError: uninitialized constant ... I have tried to find which method throws that error, but I couldn't find it. for ex. redefining "const_missing" in Object but I keep getting the same error Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire