SaveSnippets
Community
Pricing
Sign In
Get Started
Community
Public Snippets
3
Code shared by the SaveSnippets community — browse, copy, and get inspired.
All Languages
Bash
Go
HTML
Java
JavaScript
Kotlin
PHP
Python
Rust
SQL
TypeScript
#hashmap
Clear
Tags
#php
#kotlin
#bash
#go
#sql
#rust
#typescript
#html
#java
#python
#files
#utils
#strings
#http
#concurrency
#async
#json
#arrays
#security
#types
#crypto
#database
#dates
#format
Bash
Associative Array (hash map)
Bash 4+ supports key-value associative arrays. Must `declare -A` first — Bash won't infer it. Iterate keys with !arr[@].
#bash
#arrays
#associative
#hashmap
Rust
Group By a Key (fold into HashMap)
No built-in `group_by`, but `fold` into a `HashMap` does the same thing in two lines — and the type system tracks keys / values correctly.
#rust
#iterators
#group-by
#hashmap
#fold
Rust
HashMap with the entry() API
The `entry()` API is the idiomatic way to "insert if absent" or "update if present" in a single lookup. Avoids double-lookups that the explicit `contains_key` + `insert` dance would need.
#rust
#collections
#hashmap
#entry