The extra assignment is unnecessary too.

you can just do

def show
  return "Name: " + @name
end

With instance and class variables, the @'s are part of the name themselves.

This is a nice thing because you can always tell whether you're
looking at a class variable, a local variable, or an instance
variable.

On 7/5/05, Jason Foreman <threeve.org / gmail.com> wrote:
> On 7/5/05, Faisal Raja <Raja.Faisal / gmail.com> 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
> 
> 


-- 
-Dan Nugent