From: Sam Duncan Date: 2012-04-17T11:31:00+09:00 Subject: Re: Gets Returns Nil? On 17/04/12 13:39, Solomon W. wrote: > In this script: (Attached) > For some reason, when I call print_stats, for every variable, it returns > nil? Why is this? Am I doing something wrong? > > Attachments: > http://www.ruby-forum.com/attachment/7297/closercomp.rb > > Try assigning your initial values to their respective instance variables. class Player def initialize(saves, era, holds, k, bs, whip, name) @saves, @era, @holds, @k, @bs, @whip, @name = saves, era, holds, k, bs, whip, name puts "Player Loaded" puts @saves end def print_stats puts "Stats for: #{@name}" puts "----------------" puts "Saves: #{@saves}" puts "ERA: #{@era}" puts "Holds: #{@holds}" puts "Strikeouts: #{@k}" puts "Blown Saves: #{@bs}" puts "WHIP: #{@whip}" end end Sam