T. Onoma
1/17/2005 12:25:00 PM
On Monday 17 January 2005 07:16 am, benny wrote:
| dear list,
|
| just noticed an unexspected behaviour of the OpenStruct class:
|
|
| require 'ostruct'
| t = OpenStruct.new()
| t.meth1 = []
| t.send('meth1') << "hi"
| puts t.meth1.inspect
|
| this works, but
|
| t.send('meth2') = [] # => test.rb:17: syntax error t.send('meth2') = []
| puts t.meth2.inspect
aassignment itself isn't a method in Ruby, but assignment methods are (i.e.
setter methods), so try:
t.send('meth2=', [])
T