Skip to content

Latest commit

 

History

History
26 lines (15 loc) · 887 Bytes

File metadata and controls

26 lines (15 loc) · 887 Bytes

The Map.update() method

A common requirement when working with maps is to:

  • Update the value if a given key already exists
  • Set the value if it doesn't

You may be tempted to implement some conditional logic to handle this.

But the update() method offers a simpler way of doing the same thing: 👇


Found this useful? Show some love and share the original tweet 🙏

Also published on codewithandrea.com 👇


Previous Next
AsyncValue.guard() vs try/catch Riverpod: difference between ref.watch, ref.read, ref.listen