0

Ruby interprets the length of a non empty array as 0

I wanted to make a function in ruby that will take an array and an integer as an input. if the length of the array is divisible by the integer, the function will reverse each (value of the integer) elements of the array. if the length is not divisible by the integer, it will say that the array must be divisible by the integer. when i tried it with an array like [5,3,2,6,7,1] , it gave an error message saying i tried to divide by zero. can anyone help me? i didn't save the code but i will add it later.

26th Feb 2017, 8:55 AM
Michal Nemecek
Michal Nemecek - avatar
1 Respuesta
0
Just to be sure, did you also input a number to the function, or just the array?? if it says that you are trying to divide by zero, and the formula checks if the size of the array is divisible by the integer, then the bug has more to do with the integer than with the array
27th Feb 2017, 12:34 AM
Alejandro Aristizabal
Alejandro Aristizabal - avatar