DEV Community

Discussion on: Determining class of an object with case equality operator (===)

Collapse
 
baweaver profile image
Brandon Weaver

Be careful of accidentally using strict equality with === like so:

String === 's'.class

That works with == but will fail with ===.

=== is all types of fun in Ruby, especially for case statements and predicate methods like any?. It's even more fun when you realize Proc uses === for call. Taken one step further you can make your own classes which respond to === to do fun things.