In Javascript if I want to do type checking of an array index I can do something like this:
var array = [1,2,3,4,"the monster from the green lagoon"]
for (i=0; i < array.length; i++) {
if (typeof(array[i]) === 'number') {
console.log("yes these are all numbers");
}
else {
console.log("Index number " + i + " is " + array[i] +": No this is not a number");
}
}
In Ruby I don't understand how to do this. I'm trying to type check against Integers. I understand that in the Ruby world it's considered good etiquette to use the each method thus basic looping is something like this:
array = [1, 2, 3, 4, 5, 6]
array.each { |x| puts x }
The part I'm confused about is the syntax is foreign and I'm unclear where the logic goes. I haven't gotten to the actual type checking yet but from what I read it would compare against the Integer type thus:
if array[i] == Integer
Thank you.