From: Li Chen Date: 2006-12-18T00:16:55+09:00 Subject: Why the resutls are different Hi all, I try to understand the concept of variable scopes. I define two classes with very similar structures. But Ruby complains class Y only. Any comments? Thanks, Li class X def initialize(name,artist,duration) @name=name @artist=artist @duration=duration end puts "This is the name"" #{name}" end test_x=X.new(1,2,3) puts test_x.inspect >ruby variables1.rb This is the name X # >Exit code: 0 class Y def initialize(arg1,arg2,arg3) @arg1=arg1 @arg2=arg2 @arg3=arg3 end puts "This is arg1"" #{arg1}" end test_y=Y.new(1,2,3) puts test_y.inspect >ruby variables2.rb variables2.rb:15: undefined local variable or method `arg1' for Y:Class (NameError) >Exit code: 1 -- Posted via http://www.ruby-forum.com/.