What does it mean to coerce an object? Why would you do it?

Technology CommunityCategory: RubyWhat does it mean to coerce an object? Why would you do it?
VietMX Staff asked 3 years ago

To coerce an object means to force it into an expected type. One might do this in order to try and force an unknown object type into the expected type or format required by the operation. This is a common practice involved in duck typing.