开发者

How can I get a instance of a Class from a String in ruby? [duplicate]

This question already has answers here: 开发者_Python百科 Closed 11 years ago.

Possible Duplicate:

How to convert a string to a constant in Ruby?

I am wondering whether there is a way for me to convert a string to a class in ruby. What i mean by this is that, given a String like

'Fixnum'

i want a way to get the class

Fixnum

back

can someone give me an idea on how to do this?


"FixNum".classify.contantize should do it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜