Skip to content

Instantly share code, notes, and snippets.

@stevepolitodesign
Last active March 16, 2022 15:35
Show Gist options
  • Save stevepolitodesign/6cab174e5c1e72cc5d33e1eb877bee53 to your computer and use it in GitHub Desktop.
Save stevepolitodesign/6cab174e5c1e72cc5d33e1eb877bee53 to your computer and use it in GitHub Desktop.
Use with_indifferent_access to format a hash for reliable equality checks.
hash_one = { "name" => "Steve"}
# => {"name"=>"Steve"}
hash_two = { name: "Steve"}
# => {:name=>"Steve"}
hash_one == hash_two
# => false
hash_one.with_indifferent_access == hash_two.with_indifferent_access
# => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment