From: Garthy D Date: 2012-01-31T17:06:08+09:00 Subject: Re: Help me please Hi Luc, You need to add it to the Fixnum class, and use self to get at the value, like so: ---===<<< SNIP >>>===--- class Fixnum def divisions n = self i=1 while i <= n if n%i>0 i += 1 else yield n/i i += 1 end end end end 12.divisions {|x| puts x} ---===<<< SNIP >>>===--- I haven't checked your algorithm, just made the changes needed to get it to work the way you want. HTH Garth PS. Don't forget to indent. ;) On 31/01/12 13:10, luk malcik wrote: > hi, i'm the beginner in ruby. My task is change this version of code to > nonarguments method of Fixnum class using yield. That'll be passed if i > could typing for example 12.divisions{|x| puts x} and it will be works. > I try it a lot but that's my first time in ruby... and this is my > version for method with argue > > def divisions(n) > i=1 > while i<= n > if n%i>0 > i += 1 > else > yield n/i > i += 1 > end > end > end > > What i must change? > > Attachments: > http://www.ruby-forum.com/attachment/6941/zad1.rb > >