https://github.com/phxql/kotlin-default-map
A map which returns a default value for missing keys
https://github.com/phxql/kotlin-default-map
Last synced: 3 months ago
JSON representation
A map which returns a default value for missing keys
- Host: GitHub
- URL: https://github.com/phxql/kotlin-default-map
- Owner: phxql
- License: lgpl-3.0
- Created: 2016-10-25T22:28:04.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-29T18:01:51.000Z (over 9 years ago)
- Last Synced: 2025-01-08T08:14:26.598Z (over 1 year ago)
- Language: Kotlin
- Size: 56.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kotlin-default-map
A map which returns a default value for missing keys.
## Usage
```kotlin
val map = mapOf(1 to "one", 2 to "two").defaultsTo("???")
assertThat(map[1], equalTo("one"))
assertThat(map[2], equalTo("two"))
assertThat(map[3], equalTo("???"))
// Notice that value is of type String, not String?
val value: String = map[1]
```
## Downloading
### Gradle
```groovy
repositories {
maven {
url "https://dl.bintray.com/phxql/maven"
}
}
dependencies {
compile 'de.mkammerer:kotlin-default-map:1.0'
}
```
### Maven
Add this repository:
```xml
false
bintray-phxql-maven
bintray
https://dl.bintray.com/phxql/maven
```
You can then use the following Maven coordinates:
```xml
de.mkammerer
kotlin-default-map
1.0
```
## License
[LGPLv3](LICENSE)
## Maintainer
Moritz Kammerer ([@phxql](https://github.com/phxql))