# Primitive type is not a struct type?

**URL:** <https://forum.crystal-lang.org/t/primitive-type-is-not-a-struct-type/6593>\
**Category:** Help & Support\
**Created:** [February 14, 2024, 4:22pm UTC](https://forum.crystal-lang.org/t/primitive-type-is-not-a-struct-type/6593 "2024-02-14T16:22:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aiac](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aiac](https://forum.crystal-lang.org/u/aiac)\
**Post date:** [February 14, 2024, 4:22pm UTC](https://forum.crystal-lang.org/t/primitive-type-is-not-a-struct-type/6593/1 "2024-02-14T16:22:24Z")

</div>

code

```crystal
def is_struct?(t : T) : Bool forall T
  {% begin %}
    {{ T.struct? }}
  {% end %}
end

p! is_struct? 1
p! is_struct? 1.0
p! is_struct? StaticArray[0]

```

output

```auto
is_struct?(1) # => false
is_struct?(1.0) # => false
is_struct?(StaticArray[0]) # => true

```

---

<div class="post-metadata">

**Author:** ![aiac](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aiac](https://forum.crystal-lang.org/u/aiac)\
**Post date:** [February 14, 2024, 4:33pm UTC](https://forum.crystal-lang.org/t/primitive-type-is-not-a-struct-type/6593/2 "2024-02-14T16:33:02Z")

</div>

how to detect primitive type?

T.primitive?

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [February 14, 2024, 4:35pm UTC](https://forum.crystal-lang.org/t/primitive-type-is-not-a-struct-type/6593/3 "2024-02-14T16:35:02Z")

</div>

I don’t think there’s a built-in way to do this?

---

<div class="post-metadata">

**Author:** ![2f1cafc](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/2f1cafc/32/2308_2.png) [@2f1cafc](https://forum.crystal-lang.org/u/2f1cafc)\
**Post date:** [February 14, 2024, 5:44pm UTC](https://forum.crystal-lang.org/t/primitive-type-is-not-a-struct-type/6593/4 "2024-02-14T17:44:46Z")

</div>

Could you check whether it’s a sub-type of `Value` ?

```auto
def is_value?(t : T) : Bool forall T
  {% begin %}
    {{ T < Value }}
  {% end %}
end

```

---

<div class="post-metadata">

**Author:** ![aiac](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@aiac](https://forum.crystal-lang.org/u/aiac)\
**Post date:** [February 14, 2024, 5:47pm UTC](https://forum.crystal-lang.org/t/primitive-type-is-not-a-struct-type/6593/5 "2024-02-14T17:47:36Z")

</div>

thank you very much
