# Are maps with keys of type any usable?

**URL:** <https://forums.unrealengine.com/t/are-maps-with-keys-of-type-any-usable/1157389>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [May 7, 2023, 8:16am UTC](https://forums.unrealengine.com/t/are-maps-with-keys-of-type-any-usable/1157389 "2023-05-07T08:16:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![poltrr](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/poltrr/32/677016_2.png) [@poltrr](https://forums.unrealengine.com/u/poltrr)\
**Post date:** [May 7, 2023, 8:16am UTC](https://forums.unrealengine.com/t/are-maps-with-keys-of-type-any-usable/1157389/1 "2023-05-07T08:16:42Z")

</div>

Hi,

```auto
Map : [string]any = map{}
Map["Number"] = 1
Number : int = Map["Number"] ## Throws error cause Map["Number"] returns 'any' instead of 'int'.

```

Is there a way to cast the type `any` to a different type? Unless there is, it seems like using a map `[]any` is not of any use.

```auto
Number : int = int[Map["Number"]] ## Also throws an error.

```

Which I don’t mind, but I do wonder why it is allowed, cause it’s not like you can give any use to the returned values if they can’t be casted. Or can you?

Thank you!

---

<div class="post-metadata">

**Author:** ![Knight\_Breaker](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/knight_breaker/32/1194711_2.png) [@Knight\_Breaker](https://forums.unrealengine.com/u/Knight_Breaker)\
**Post date:** [May 7, 2023, 8:37am UTC](https://forums.unrealengine.com/t/are-maps-with-keys-of-type-any-usable/1157389/2 "2023-05-07T08:37:35Z")

</div>

Not an answer to your question but I asked this here and waiting for an official answer:

> [@Is \`false\` a bottom type in Verse?](https://forums.unrealengine.com/t/is-false-a-bottom-type-in-verse/1156905/3):
>
> Speaking of any. What is the type of any actually? Its instance is an existential, basically a box that can hold anything, but I’m not sure about the actual type. Is it a special interface of some sort or just a special built-in type? Furthermore, are there any plans to permit dynamic downcasts from an instance of type any? Something: any = ... if (Number := int[Something]) {} # this is currently not permitted. Using any to box multiple different types and then dynamically restore their actu…

Dynamic downcasting from `any` is currently not supported. This isn’t limited to maps or arrays, but generally. I hope we’ll get that feature before we get the new verse virtual machine update in 2024.

---

<div class="post-metadata">

**Author:** ![AndrewScheidecker](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/andrewscheidecker/32/926976_2.png) [@AndrewScheidecker](https://forums.unrealengine.com/u/AndrewScheidecker)\
**Post date:** [May 7, 2023, 12:45pm UTC](https://forums.unrealengine.com/t/are-maps-with-keys-of-type-any-usable/1157389/3 "2023-05-07T12:45:29Z")

</div>

Maps require that their keys are comparable for equality at runtime, and `any` includes values that aren’t. The `comparable` type captures exactly this constraint, so you should be able to use it as the key of a map: e.g. `Map : [comparable]int`.

From your example, it looks like you’re trying to use `any` for values in a map, not the keys. That is allowed, but because `any` isn’t even comparable, there’s very little you can do with those values. Using `comparable` for the value would be slightly more useful, but we don’t yet support dynamic downcasting from it.

See also: [Is `false` a bottom type in Verse? - #4 by AndrewScheidecker](https://forums.unrealengine.com/t/is-false-a-bottom-type-in-verse/1156905/4)
