Skip to content

Latest commit

 

History

History
11 lines (8 loc) · 405 Bytes

responds_to.md

File metadata and controls

11 lines (8 loc) · 405 Bytes

responds_to?

The pseudo-method responds_to? determines whether a type has a method with the given name. For example:

a = 1
a.responds_to?(:abs)    #=> true
a.responds_to?(:size) #=> false

It is a pseudo-method because it only accepts a symbol literal as its argument, and is also treated specially by the compiler, as explained in if var.responds_to?(...).