---
title: "Discussion on \"Mutable Dictionary Keys in Swift: A Bug Waiting to Happen\" | Hashnode"
description: "Discussion on \"Mutable Dictionary Keys in Swift: A Bug Waiting to Happen\". Let's imagine we have cartItems dictionary that has product as key and number of items as value\nstruct Product: Hashable {\n    var id: Int\n    var name: String\n}\n\nvar cartItems = [Product: Int]()\n\nvar"
url: "https://hashnode.com/posts/mutable-dictionary-keys-in-swift-a-bug-waiting-to-happen/69d05065e466e2b762b2711b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Mutable Dictionary Keys in Swift: A Bug Waiting to Happen](https://hudaios.hashnode.dev/mutable-dictionary-keys-in-swift-a-bug-waiting-to-happen?utm_source=hashnode&utm_medium=feed)

Let's imagine we have cartItems dictionary that has product as key and number of items as value struct Product: Hashable { var id: Int var name: String } var cartItems = \[Product: Int\]() var

Apr 3 · 3 min read · hudaios.hashnode.dev  
Read the article

-   [#swift](https://hashnode.com/tag/swift)
-   [#dictionary](https://hashnode.com/tag/dictionary)
-   [#bug](https://hashnode.com/tag/bug)
-   [#ios-development](https://hashnode.com/tag/ios-development)

## Written by

[huda elhady](https://hashnode.com/@huda_elhady)

@huda\_elhady

  
[View profile](https://hashnode.com/@huda_elhady)

iOS Developer

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
