ruby执行字符串代码

str = "a='abcd'; a.reverse"

字符串str为ruby代码,执行方法eval

eval str
=> "dcba"
posted @ 2017-05-31 16:59  wangyuyu  阅读(614)  评论(0编辑  收藏  举报