From: Russell Fulton Date: 2006-07-09T11:25:14+09:00 Subject: Re: accessors and anonymous classes unknown wrote: > Hi -- > > On Sun, 9 Jul 2006, Russell Fulton wrote: > >> @@hostService = Class.new( Section ) { >> >> attr_reader = :services, :converted, :actions, :patterns, >> :realTime, >> :periodic, :files >> attr_writer = :converted > > Just looking at this quickly: you're assigning to local variables > called attr_reader and attr_writer, when what you want to do is call > the methods of those names: > > attr_reader :services, :converted, :actions, .... > > Thanks David! Doh! it had to be something simple and obvious. And that's why my orginal test program worked fine - it was correct. I see ruby suffers from the same problem as perl -- just about anything is valid syntax, so it compiles but the semantics are not quite what you intended ;) In a past life I spent half each day for several years as a programming consultant in a large university (in the days of mainframes) I lost count of the number of times that I had people come in with a listing of their program, lay it out in front of me and start explaining the latest incomprehensible behaviour then suddenly stop, go bright red and quickly gather everything up muttering that they now knew what the problem was. I know how they feel :) Russell (who has just spent an hour or so carefully paring down his program to 10 lines that illustrates the problem :) -- Posted via http://www.ruby-forum.com/.