鲁比有类似Python评估的东西吗?我在搜索谷歌,我不知道我是怎么搜索的,但我在上面找不到任何东西,也找不到如何使用它(如果有的话)
在python中,我想这样做
def doEval(object):
return repr(eval(object))
上面的代码可以在python的idle或其他东西中执行并运行doEval('print(“hello”)')),它将打印“hello”,然后返回“None”来表示它已执行,在ruby中,我不介意它不做nil,但我希望它进行eval
在ruby里有这样的东西吗?谢谢。在
Googling "ruby eval" quickly reveals that the answer is yes.
试试这个:
http://www.ruby-doc.org/core-2.0.0/Kernel.html#method-i-eval
相关问题 更多 >
编程相关推荐