Nathan Viswa wrote:

> I:\RubyNV>
> 
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
> 
> if i use it stand alone it does not work!!
> 
> class Person

> steve = Person.new("Viswa")
> 
> #puts steve.lname, 'x1' # err undefined methid lname
> #puts steve.lname(), 'x2' # err as above
> #puts steve.lname("nv"), 'x2' # err as above
> 
Here is another attempt, look at the following and notice that I had to 
define the method lname() that takes in a parameter to get the results 
that you wanted..

This is not the way to do things, just meant to show how it can be 
done.. :)

irb(main):001:0> class Person
irb(main):002:1> def lname(myarg = nil)
irb(main):003:2> @lname = myarg if myarg
irb(main):004:2> @lname
irb(main):005:2> end
irb(main):006:1> def lname=(myarg); lname(myarg); end
irb(main):007:1> end
=> nil
irb(main):008:0> p = Person.new
=> #<Person:0x2ac90263d940>
irb(main):009:0> p.lname = "jack"
=> "jack"
irb(main):010:0> p.lname("bill")
=> "bill"
irb(main):011:0> p.lname
=> "bill"

hth

ilan

-- 
Posted via http://www.ruby-forum.com/.