From: Shawn Anderson Date: 2008-04-15T02:32:20+09:00 Subject: Re: My Longsword is broken. ------=_Part_17136_24876685.1208194336327 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline A few ruby basics: foo_bar is a variable name (all lowercase separated by underscores) FOO_BAR is a constant (all caps separated by underscore) FooBar is a class or module (starts with cap and is bumpy case) So: Longsword = Sword.new(rand(8)+1) is a little funky. Secondly, The ... Apparently, I type too slow and Gerardo has finished my work for me. Hope that helps. /Shawn On Mon, Apr 14, 2008 at 10:08 AM, Ben Galyean wrote: > Hello all, > > Just started my first Ruby prog and hit a snag almost instantly. I > simply wish to have my selected weapon do it's prescribed damage as I > intend (in this case, it's 1-8 damage). Complete noob here so any help > at all would be greatly appreciated. The following is a re-creation of > my problem: > > #*********************************** > class Sword > attr_accessor(:realDam) > > def initialize(aRealDam) > @realDam = aRealDam > end > end > > Longsword = Sword.new(rand(8)+1) > weapon = Longsword > > begin > > 5.times {p weapon.realDam} > puts > 5.times {p (rand(8)+1)} > > end > #************************************* > > Output looks like this: > > #****Current Longsword damage (Picks a number and 'keeps' it).**** > 6 > 6 > 6 > 6 > 6 > > #****Intended output for the longsword here**** > 6 > 8 > 8 > 4 > 8 > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_17136_24876685.1208194336327--