benny1
(benny)
1
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
is it a bug or am I missing something?
greetings,
benny
T_Onoma
(T. Onoma)
2
aassignment itself isn't a method in Ruby, but assignment methods are (i.e.
setter methods), so try:
t.send('meth2=', [])
T
···
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