# Code review: initialization via tuple of tuples

**URL:** <https://ziggit.dev/t/code-review-initialization-via-tuple-of-tuples/5548>\
**Category:** Help\
**Tags:** language\
**Created:** [August 8, 2024, 4:36am UTC](https://ziggit.dev/t/code-review-initialization-via-tuple-of-tuples/5548 "2024-08-08T04:36:42Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dimdin](https://ziggit.dev/user_avatar/ziggit.dev/dimdin/32/1457_2.png) [@dimdin](https://ziggit.dev/u/dimdin)\
**Post date:** [August 8, 2024, 7:35am UTC](https://ziggit.dev/t/code-review-initialization-via-tuple-of-tuples/5548/2 "2024-08-08T07:35:38Z")

</div>

### 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.

```zig
    fn isString(comptime v: anytype) bool {
        const str: []const u8 = "";
        return @TypeOf(str, v) == []const u8;
    }

```

---

_[View the full topic](https://ziggit.dev/t/code-review-initialization-via-tuple-of-tuples/5548)._
