Undefined method `each' for 4:Fixnum

undefined method `each’ for 4:Fixnum

How can I solve this error.

Thanks

Ravi D. wrote:

undefined method `each’ for 4:Fixnum

How can I solve this error.

Don’t call .each on a number.

Thanks

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Instead of each maybe u should use times…

for example
4.times

Ash

Quoting Ravi D. [email protected]:

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