Crystal Expert · Lesson 5

Object protocols: to_s(io), inspect(io), equality, hash and clone

Make your types print, compare, hash and copy correctly by overriding the IO-based protocol methods instead of building throwaway strings.

Lessons · Crystal Expert · Lesson 5 of 10

Object protocols: to_s(io), inspect(io), equality, hash and clone

Make your types print, compare, hash and copy correctly by overriding the IO-based protocol methods instead of building throwaway strings.

Illustration for Crystal
Make your types print, compare, hash and copy correctly by overriding the IO-based protocol methods instead of building throwaway strings.