From: Jeremiah Dodds Date: 2011-10-05T15:00:25+09:00 Subject: Re: question about method On Wed, Oct 5, 2011 at 12:46 AM, Joseph S. wrote: > FIXED IT! i may be a beginner but i figured it out. should have been > using classes from the start, silly me. > Awesome that you found a solution! The problem with your initial try wasn't that you weren't using classes though, it was that you weren't saving the value returned from your function. def roll_d20 1 + rand(20) end def attack_roll if roll_d20 > AC print "Attack roll is #{roll_d20} vs. AC #{AC}. Hit!" else roll_d20 <= AC print "Attack roll is #{roll_d20} vs. AC #{AC}. Miss!" end end 10.times do print attack_roll end In the code above, each time the string "roll_d20" happens in the body of attack_roll, it's calling the function and returning a new number since functions in ruby return the value of their last statement. So it looked like the output was wrong because what you were printing was a *new* number instead of the number being compared. In your new code, you assign the result of the roll to a variable (which, btw, is done in a bit of an odd way, it's very uncommon to want a variable from outside a class to be accessed within it directly like $d20 is, but don't worry you're on the right path), and that variable is then compared. You could modify your old code to work the same way (and I suggest you do, it's always good to apply new knowledge to old stuff). Keep reading and coding and learning, and you'll be on top of things in no time!