From: Tim Hunter Date: 2008-06-10T06:01:57+09:00 Subject: Re: C++ 2 Ruby Jed Kowalski wrote: > Avdi Grimm wrote: >> You might have better luck asking for help with specific sections of >> code, rather than asking us to rewrite a whole program. Try doing a >> best-guest translation to Ruby on your own, and asking about the parts >> you have trouble with. > > ok so, here's the first problem: > def initialize (cen, ile, nn) > @price=cen > @amount=ile > @name=nn > @bought=0 > end > > > def change(x) > amount-- > bought++ > return x-price //WHATS WRONG HERE? > end > > and I get: > > gut.rb:13: void value expression > return x-cena > ^ > gut.rb:13: syntax error, unexpected tIDENTIFIER, expecting kEND > return x-cena > Well, if you want to refer to the @amount, @bought, and @price instance variables in the change() method you have to use the correct names. Also Ruby doesn't have the -- and ++ methods. def change(x) @amount -= 1 @bought += 1 return x - @price end -- RMagick: http://rmagick.rubyforge.org/ RMagick 2: http://rmagick.rubyforge.org/rmagick2.html