From: Michael Winterstein Date: 2009-11-28T14:56:43+09:00 Subject: Local variables can't be accessed from outside, right? Hi, I've been trying to figure out metaprogramming and I've mostly got it figured out, but in doing so I ran across this example: class A def initialize @a = 11 @@a = 22 a = 33 end @a = 1 @@a = 2 a = 3 end This was given as a posed question (can you access all the variables) and a particular order of the output was given (specifically, 1 2 3 11 22 33). Getting at the instance variables, and even the class variables doesn't seem that hard to me. But it seems to me there's no way to get at the local variable a's. The way it was asked makes me think it might be possible, but I'm reasonably sure it isn't. However, I'm fairly new to Ruby and just wrapping my mind around the metaprogramming ideas and realize I could easily be missing something. I think a trick like puts A.new would be a lame solution, as would finding it somehow in memory after the class definition end statement (though that might be interesting to know if Ruby can do that). -- Posted via http://www.ruby-forum.com/.