From: Chad Perrin Date: 2012-02-03T06:11:11+09:00 Subject: Re: moveto(x,y) method On Fri, Feb 03, 2012 at 05:56:29AM +0900, luk malcik wrote: > How can I declare moveto method if I want to change co-ordinates (x,y) > that are actually in object. That's my code: > > > module Domieszka > attr_accessor :@x > attr_accessor :@y > > def inspect > "You are in: #{@x} #{@y}" > end > > def moveto(x,y) > > end > end module Domieszka attr_accessor :x attr_accessor :y # assuming @x and @y are defined somewhere, perhaps in a class # where you plan to include this module def inspect "You are in #{@x} #{@y}" end def move_to(x,y) @x = x @y = y end end -- Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]