From: Jason Foreman Date: 2005-07-06T04:24:19+09:00 Subject: Re: What is wrong in this code ... ??? On 7/5/05, Faisal Raja wrote: > Hello , > Well Im new to programming in Ruby Language ( Infact only an hour back > i started it ) . > > class Student > > def initialize(name) > > @name = name > > end > > def show > > s = "Name : " + name > return s > > > end > end > > > st = Student.new("Abc") ; > st.inspect > > I have Windows Xp Sp2 n when i run this program on console , it doesn't > show me anything . There is no error but it is also not shwoing me > anything . > you aren't printing anything. Try putting "p st.inspect" instead of just "st.inspect". > st.inspect should show info > st.to_s also doesn't show anything > > > if i write st.show > it also doesn't work . this is because you reference 'name' which is a local variable, but what you meant is to access '@name' which is the instance variable. Try this instead: s = "Name: " + @name > I wuld be thankful if u people help me out > Thanks in advance > > > Jason