# Nullable type error

**URL:** <https://discuss.kotlinlang.org/t/nullable-type-error/14136>\
**Category:** Support\
**Created:** [September 3, 2019, 1:35pm UTC](https://discuss.kotlinlang.org/t/nullable-type-error/14136 "2019-09-03T13:35:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stenlee](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/stenlee/32/6623_2.png) [@stenlee](https://discuss.kotlinlang.org/u/stenlee)\
**Post date:** [September 3, 2019, 1:35pm UTC](https://discuss.kotlinlang.org/t/nullable-type-error/14136/1 "2019-09-03T13:35:13Z")

</div>

```kotlin
val word: String = "abracadabra"
val freqMap: MutableMap<Char, Int> = HashMap<Char, Int>().withDefault { 0 } word.forEach { freqMap[it] += 1 }

```

results in this compile time error:  
`Operator call corresponds to a dot-qualified call 'freq[it].plusAssign(1)' which is not allowed on a nullable receiver 'freq[it]'.`

What the hack!?  
Why is freq[it] considered `Int?` when `freqMap` is of type `MutableMap<Char, Int>`

(Kotlin plugin 1.3.50-release-IJ2019.1.1)

---

<div class="post-metadata">

**Author:** ![SackCastellon](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sackcastellon/32/4553_2.png) [@SackCastellon](https://discuss.kotlinlang.org/u/SackCastellon)\
**Post date:** [September 3, 2019, 1:52pm UTC](https://discuss.kotlinlang.org/t/nullable-type-error/14136/2 "2019-09-03T13:52:45Z")

</div>

See documentation: [get - Kotlin Programming Language](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/get.html)

Also there is a previous post that addresses this: [Map.withDefault not defaulting? - #2 by ilya.gorbunov](https://discuss.kotlinlang.org/t/map-withdefault-not-defaulting/7691/2)

---

<div class="post-metadata">

**Author:** ![stenlee](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/stenlee/32/6623_2.png) [@stenlee](https://discuss.kotlinlang.org/u/stenlee)\
**Post date:** [September 3, 2019, 2:20pm UTC](https://discuss.kotlinlang.org/t/nullable-type-error/14136/3 "2019-09-03T14:20:31Z")

</div>

Thank you, got it.
