undefined method `each' for 4:Fixnum
How can I solve this error.
Thanks
undefined method `each' for 4:Fixnum
How can I solve this error.
Thanks
Ravi Dtv wrote:
undefined method `each' for 4:Fixnum
How can I solve this error.
Don't call .each on a number.
Thanks
Best,
Quoting Ravi Dtv <lists@ruby-forum.com>:
undefined method `each' for 4:Fixnum
How can I solve this error.
What are you trying to do? 'each' is usually applied to an array, a hash, or a range. It doesn't make sense for a Fixnum. Do you want
irb(main):001:0> 4.times{|i| puts i} 0 1 2 3 => 4 irb(main):002:0>
or:
irb(main):002:0> (2..4).each{|i| puts i} 2 3 4 => 2..4 irb(main):003:0>
HTH, Jeffrey
Instead of each maybe u should use times....
for example 4.times
Ash