# Re: Can we define data types explicitly?

**URL:** <https://www.ruby-forum.com/t/re-can-we-define-data-types-explicitly/118830>\
**Category:** Ruby\
**Created:** [October 31, 2007, 2:06pm UTC](https://www.ruby-forum.com/t/re-can-we-define-data-types-explicitly/118830 "2007-10-31T14:06:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 31, 2007, 2:06pm UTC](https://www.ruby-forum.com/t/re-can-we-define-data-types-explicitly/118830/1 "2007-10-31T14:06:00Z")

</div>

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
