# How to achieve this in crystal?

**URL:** <https://forum.crystal-lang.org/t/how-to-achieve-this-in-crystal/6169>\
**Category:** Help & Support\
**Created:** [November 16, 2023, 10:38am UTC](https://forum.crystal-lang.org/t/how-to-achieve-this-in-crystal/6169 "2023-11-16T10:38:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![maverk41374](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@maverk41374](https://forum.crystal-lang.org/u/maverk41374)\
**Post date:** [November 16, 2023, 10:38am UTC](https://forum.crystal-lang.org/t/how-to-achieve-this-in-crystal/6169/1 "2023-11-16T10:38:20Z")

</div>

```auto
myhash : Hash(String, String ????? ) = { "name" => "test, "age" => 99}

puts myhash

```

i want the word `age` to be a string but its value should be `number` how ?

---

<div class="post-metadata">

**Author:** ![MistressRemilia](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/mistressremilia/32/2585_2.png) [@MistressRemilia](https://forum.crystal-lang.org/u/MistressRemilia)\
**Post date:** [November 16, 2023, 10:42am UTC](https://forum.crystal-lang.org/t/how-to-achieve-this-in-crystal/6169/2 "2023-11-16T10:42:43Z")

</div>

You could do

```auto
myhash : Hash(String, String | Int32) = {"name" => "test", "age" => 99}
puts myhash

```

You could also do this to get the type of the literal:

```auto
puts typeof({"name" => "test", "age" => 99})

```

---

<div class="post-metadata">

**Author:** ![maverk41374](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@maverk41374](https://forum.crystal-lang.org/u/maverk41374)\
**Post date:** [November 16, 2023, 10:43am UTC](https://forum.crystal-lang.org/t/how-to-achieve-this-in-crystal/6169/3 "2023-11-16T10:43:14Z")

</div>

doesn’t work my mate

---

<div class="post-metadata">

**Author:** ![MistressRemilia](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/mistressremilia/32/2585_2.png) [@MistressRemilia](https://forum.crystal-lang.org/u/MistressRemilia)\
**Post date:** [November 16, 2023, 10:43am UTC](https://forum.crystal-lang.org/t/how-to-achieve-this-in-crystal/6169/4 "2023-11-16T10:43:38Z")

</div>

How doesn’t it work? Can you give me an error message?

---

<div class="post-metadata">

**Author:** ![maverk41374](https://avatars.discourse-cdn.com/v4/letter/m/ce73a5/32.png) [@maverk41374](https://forum.crystal-lang.org/u/maverk41374)\
**Post date:** [November 16, 2023, 10:44am UTC](https://forum.crystal-lang.org/t/how-to-achieve-this-in-crystal/6169/5 "2023-11-16T10:44:18Z")

</div>

sorry it works
