From: Hassan Schroeder Date: 2011-03-20T08:24:04+09:00 Subject: Re: Using value from variable in .times method? On Sat, Mar 19, 2011 at 4:16 PM, Jen wrote: > I confess I don't know a lot of the technical stuff about class Fixnum, as > I've not really needed to until now. Time to learn :-) > Currently I am getting the value of 'pop' from the user with the following > code: > >  puts "please enter a population size" > pop = gets.chomp $ irb >> foo = "1" => "1" >> foo.class.name => "String" >> bar = 1 => 1 >> bar.class.name => "Fixnum" >> bar.times { puts "cool" } cool => 1 >> foo.times { puts "cool" } NoMethodError: undefined method `times' for "1":String from (irb):6 >> -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com twitter: @hassan