DEV Community

Cover image for #to_s or #to_str? Explicitly casting vs. implicitly coercing types in Ruby

#to_s or #to_str? Explicitly casting vs. implicitly coercing types in Ruby

Tom de Bruijn on September 25, 2018

Type coercion is the changing of an object's type into another type, together with its value. For example, changing an Integer into a String with #...
Collapse
 
ben profile image
Ben Halpern

Really great post that gets to the heart of Rubyism.

Collapse
 
jrtibbetts profile image
Jason R Tibbetts

I don't think that I'll ever forget the Michael Keaton and Leonard Nimoy analogies. Good stuff.