# How to check if something is a string?

**URL:** <https://ziggit.dev/t/how-to-check-if-something-is-a-string/5857>\
**Category:** Help\
**Tags:** language\
**Created:** [September 2, 2024, 6:58am UTC](https://ziggit.dev/t/how-to-check-if-something-is-a-string/5857 "2024-09-02T06:58:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tensorush](https://ziggit.dev/letter_avatar_proxy/v4/letter/t/6a8cbe/32.png) [@tensorush](https://ziggit.dev/u/tensorush)\
**Post date:** [September 2, 2024, 7:08am UTC](https://ziggit.dev/t/how-to-check-if-something-is-a-string/5857/2 "2024-09-02T07:08:38Z")

</div>

Hi @aakashns, welcome to Ziggit!

Check this reply from @dimdin:

> [@Code review: initialization via tuple of tuples](https://ziggit.dev/t/code-review-initialization-via-tuple-of-tuples/5548/2):
>
> A compile time trick. As you probably already realized, the type of a string is not []const u8 but a 0 sentinel const array of u8 with the length of the string as size. This is impossible to match as type. But I devised a trick to detect if a anytype value is an actual string. @TypeOf can have multiple arguments and returns the type that all the arguments can coerce to. fn isString(comptime v: anytype) bool { const str: []const u8 = ""; return @TypeOf(str, v) == []const u8…

Not at all a noob question, btw 😉

---

_[View the full topic](https://ziggit.dev/t/how-to-check-if-something-is-a-string/5857)._
