Re: Can we define data types explicitly?

You can use is_a? or there is kind_of? and instance_of? methods

so you could test as follows

arr.each do |a|
if a.is_a? Integer
#do stuff here
end
end

You can also use this in a case construct.

the ‘Integer’ is the type - you can also have things like Bignum,
Fixnum, Numeric, String, Object, Array etc.

HTH

Clive