# Destructuring declaration for Map or any interface with get(String)

**URL:** <https://discuss.kotlinlang.org/t/destructuring-declaration-for-map-or-any-interface-with-get-string/18729>\
**Category:** Language Design\
**Created:** [August 10, 2020, 10:28am UTC](https://discuss.kotlinlang.org/t/destructuring-declaration-for-map-or-any-interface-with-get-string/18729 "2020-08-10T10:28:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex22](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/alex22/32/7822_2.png) [@alex22](https://discuss.kotlinlang.org/u/alex22)\
**Post date:** [August 10, 2020, 10:28am UTC](https://discuss.kotlinlang.org/t/destructuring-declaration-for-map-or-any-interface-with-get-string/18729/1 "2020-08-10T10:28:41Z")

</div>

Would be nice to have any Object and Map destructuring declaration (Like in TypeScript) translated into

```auto
val (name, age) = map

val name = person["name"]!!
val age = person["age"]!!

```

Or maybe use `val { name, age } = map` if it’s needs to be distinguished from `componentN` destructuring.

---

<div class="post-metadata">

**Author:** ![wdoker](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wdoker/32/4748_2.png) [@wdoker](https://discuss.kotlinlang.org/u/wdoker)\
**Post date:** [August 10, 2020, 11:00am UTC](https://discuss.kotlinlang.org/t/destructuring-declaration-for-map-or-any-interface-with-get-string/18729/2 "2020-08-10T11:00:08Z")

</div>

You can use local delegated properties:

```auto
val map = mapOf(
    "name" to "John Doe",
    "age" to 25
)

val name: String by map
val age: Int by map

```

[https://kotlinlang.org/docs/reference/delegated-properties.html#storing-properties-in-a-map](https://kotlinlang.org/docs/reference/delegated-properties.html#storing-properties-in-a-map)

---

<div class="post-metadata">

**Author:** ![alex22](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/alex22/32/7822_2.png) [@alex22](https://discuss.kotlinlang.org/u/alex22)\
**Post date:** [August 11, 2020, 10:43am UTC](https://discuss.kotlinlang.org/t/destructuring-declaration-for-map-or-any-interface-with-get-string/18729/3 "2020-08-11T10:43:15Z")

</div>

Would it work for such case as one-line assigning property to local variable?

`val { request_id } = result`

versus

`val request_id = result.request_id`
