From: mathew Date: 2005-07-09T02:50:48+09:00 Subject: Re: What is wrong in this code ... ??? Well, if we're doing stylistic suggestions... :-) class Student attr_accessor :name def initialize(name) @name = name end def to_s return "Name: #{@name}" end end attr_accessor is an easy way to set up a read/write instance variable; it creates an accessor method so you can go object.name = "John Smith" or puts object.name There's also attr_reader to set up a read-only field, and attr_writer for write-only. The to_s method is the standard method used to convert an object to a string; so if you define it to be something sensible, you can just print or puts the object directly. So, we can now do s = Student.new("John Smith") puts s s.name = "John P. Smith" puts s.name mathew