您如何通过变量访问操作员/ 方法?
因此,而不是这样:
c = Computer.new
c.computer_name = "bla"
c.operating_system = "Windows XP"
c.user_name = "joesmith"
c.save
(外加更多)
我要用散列并动态地指定值 :
c = Computer.new
params.each do |key,val|
c."#{key}" = val.to_s
end
c.save
还有,这里的正确术语是什么?