On Fri, May 25, 2012 at 8:38 AM, Robinson Risquez <lists / ruby-forum.com>wrote:
>
>> Hi all, I write the following problem to see if you can clarify me:
>> How I can modify an attribute of an object in a method?, Eg:
>>
>> -----------  CLIPPED ----------
>>
>> I explain: I want the attribute @attribute (which I pass as a parameter
>> to the method adder) will be modified in the method adder (adding 1)
>> constantly, printing its output in the while cycle.
>>
>
Hope this helps  .....

 class SomeClass
  attr_accessor :attribute

  def initialize(attribute)
    @attribute = attribute
  end
end

val = SomeClass.new(5)

k=0
while (k<10) do
  puts val.attribute+=1
  k+=1
end

cheers,
saji
-- 

Saji N Hameed,
ARC-ENV, Center for Advanced Information Science and Technology,
University of Aizu, Tsuruga, Ikki-machi,
Aizuwakamatsu-shi, Fukushima 965-8580,
Japan

Tel: +81242 37-2736
Fax:+81242 37-2760
 email: saji / u-aizu.ac.jp
 url: http://www.u-aizu.ac.jp
 bib: http://www.researcherid.com/rid/B-9188-2009