From: "jchris@..." Date: 2005-11-25T03:27:27+09:00 Subject: Re: syntax error when defining index setter []= Thanks Yuri, unfortunately my problems is not as simple. If all I needed was an array I could write class T attr_accessor :items def initialize @items = [] end end but what I need is something that acts like an array from outside of the class, but handles transformations to and from a more complex data structure "behind the scenes", ie: class List < ActiveRecord::Base has_many :middlemen def items middlemen.collect {|middleman| middleman.item} end def items=(new_items) new_middlemen = [] new_items.each do |new_item| new_middlemen << Middleman.create :item => new_item end middlemen = new_middlemen end def items[]=(index, new_item) #### this line gives a syntax error new_middleman = Middleman.create :item => new_item middlemen[index] = new_middleman end end I could take this to a Rails forum, but it is more of a Ruby question, as matter of syntax are arising. Running up against this error makes me think I will come up against more when trying to define items<< etc. Perhaps better would be to create a dummy object (Array) and have it run an observer pattern on itself (or something like it). When the array is changed, it would push those changes through to the middlemen. Even this is not as clean as I'd like it to be, but maybe there is an easier way that I'm just not seeing. Thanks Chris