Type ‣ Tuple ᴾᴴᴾ - chung-leong/zigar GitHub Wiki

JavaScript | PHP


A tuple in the Zig language is basically an anonymous struct with sequential numeric field names. You don't specify the names when you define one:

pub const tuple = .{ 123, 3.14, .hello };

In PHP, a tuple is treated like an array:

<?php

$m = zigar_use(__DIR__ . '/tuple-example-1.zig');

for ($i = 0; $i < count($m->tuple); $i++) {
    echo $m->tuple[$i], "\n";
}
foreach ($m->tuple as $element) {
    echo $element, "\n";
}
print_r((array) $m->tuple);
print_r($m->tuple->__plain);
123
3.14
hello
123
3.14
hello
Array
(
    [0] => 123
    [1] => 3.14
    [2] => hello
)
Array
(
    [0] => 123
    [1] => 3.14
    [2] => hello
)

Types

⚠️ **GitHub.com Fallback** ⚠️