def myhelper(object, attributes = []) attributes.each do |attr| object.attr end end
myhelper Person, [:title, :name]
我试图实现的是亲自打印一个属性列表,但是对象.attr在myhelper中,方法不起作用。
我该怎么做?
尝试 object.send(attr)
object.send(attr)
另外,你想做一张地图吗?