Why are symbols typically used as hash keys instead of strings?

Technology CommunityCategory: RubyWhy are symbols typically used as hash keys instead of strings?
VietMX Staff asked 3 years ago

Strings are mutable while symbols are immutable. Though Ruby internally makes an immutable copy of a string when used as a hash key, comparing two symbols is faster than comparing two String objects. This is also a convention.