a = Struct.new(:c).new(1) b = Struct.new(:c).new(2) a.send(:c) => 1 b.send(:c) => 2 a.send(:c) = b.send(:c)
最后一行导致错误:
Syntax error,unexpected '=',expecting $end a.send(:c) = b.send(:c) ^
a.send(:c=,b.send(:c))
foo.bar = baz不是调用方法栏后跟一个赋值 – 它是一个调用方法bar =.所以你需要告诉send来调用该方法.