Problems with Modulo operator Ruby: Why am I getting "undefined method `%' for 1..100:Range"? -
For some reason I'm getting the error 1..100 for the undefined method '%': Category When I run the following code:
[1..100] .each do | X | If x% 3 == 0 & amp; Amp; X% 5 == 0 puts "CracklePop" elsif x% 3 == 0 "Crackle" elsif x% 5 == puts "pop" and "x" end and gives x end Any ideas what's going on?
This is a bad syntax for categories.
You have created an array with 1 element, and that element is itself 1..100 what you wrote is [(1.100)] Is equal to. You are running once again on the External array, and set x to (1..100)
Are (1..100) .each , which invokes every on the category, not an array in which category Includes.
Comments
Post a Comment