您如何通过变量访问运算符/方法?
所以代替这个:
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
另外,这里的正确术语是什么?