From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-07-01T06:04:20+09:00 Subject: Re: why can't I access my instance variables? On Tue, 01 Jul 2003 06:36:15 +0900, Donglai Gong wrote: > I'm having trouble accessing instance variables directly. What's wrong > with this... [snip] > var1 set. > test.rb:13: undefined method `var1' for # (NoMethodError) Try this (untestted)... does it work ? class Level1 def initialize @var1='var1 set.' end attr_reader :var1 def printvar1 @var1 end end l1=Level1.new print l1.printvar1, "\n" print l1.var1 -- Simon Strandgaard