Does ruby 1.9.2 have an is_a? function?

前端 未结 6 1091
忘掉有多难
忘掉有多难 2020-12-17 06:59

I googled that there is an is_a? function to check whether an object is an integer or not.

But I tried in rails console, and it doesn\'t work.

I

6条回答
  •  余生分开走
    2020-12-17 07:27

    I wanted something similar, but none of these did it for me, but this one does - use "class":

    a = 11
    a.class
    => Fixnum
    

提交回复
热议问题