From: Austin Ziegler Date: 2002-10-16T11:50:33+09:00 Subject: instance_eval & attribute accessors There appears to be some bizarre behaviour with instance_eval with a block. I'm using Andy & Dave's constructor block technique, and while I can do: Mod::Klass::new { accessor = true } It doesn't work unless I do: Mod::Klass::new { self.accessor = true } It doesn't matter whether this is: def accessor=(a) @accessor = a end or attr_accessor :accessor Note also that it doesn't matter if I do: Mod::Klass::new { accessor=(true) } However, if I have a normal function: Mod::Klass::new { init_accessor(true) } It works just fine. Can anyone explain why; is this a limitation of instance_eval? Is there a way to make the first version work without using self? Why would using the assignment method or accessor be strange? I don't necessarily want to have people access the variable directly -- most of the variables have special assignment methods. So ... what's up? -austin -- Austin Ziegler, austin@halostatue.ca on 2002.10.15 at 22.28.29