From: Chad Perrin Date: 2012-02-03T12:11:57+09:00 Subject: Re: problem with method On Fri, Feb 03, 2012 at 11:55:13AM +0900, luk malcik wrote: > Why method pole= doesn't work?? > > Kolo = Struct.new (:x,:y,:r) > Kwadrat = Struct.new (:x,:y,:a) > Prostokat = Struct.new (:x,:y,:a,:b) > > module Domieszka > attr_accessor :x, :y > > def moveto(x,y) > @x = x > @y = y > end > end > > class Kolo > include Domieszka > def pole= > @r = r > pole = r * Math.PI > return pole > end > end I'm not entirely sure what you're trying to do. Does this accomplish what you want? class Kolo include Domieszka def pole=(r) @r = r r * Math::PI end end Note that PI is a constant within Math's namespace, and not a method. The period is used as a method call operator; the double-colon is a namespace separator, used to access constants within the module's namespace. Also note that the pole= definition needs to have an argument defined for it if you want to use that argument -- which I think is what you were trying to do with that "r". -- Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]