• ruby »
  • is_a? VS kind_of? VS instance_of?

is_a? VS kind_of? VS instance_of?

is_a? VS kind_of? VS instance_of?

kind_of? and is_a? are synonymous.instance_of? is different from the other two in that it only returns true if the object is an instance of that exact class, not a subclass.

example:

refer to: http://stackoverflow.com/questions/3893278/ruby-kind-of-vs-instance-of-vs-is-a

This entry was posted in ruby

Leave a Reply

电子邮件地址不会被公开。

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">