如何在 hacklang 中迭代形状的字段?
How to iterate fields of a shape in hacklang?
假设我有这样的身材
$something = shape(
'some_key' => ...,
'another_key' => ...,
...
);
如何迭代形状的每个字段?我正在寻找这样的东西
foreach ($something as $key) {
...
}
首先使用内置 HH\Shapes::toDict
转换为 dict
然后迭代:
foreach(HH\Shapes::toDict($something) as $k => $v) {
// ...
}
假设我有这样的身材
$something = shape(
'some_key' => ...,
'another_key' => ...,
...
);
如何迭代形状的每个字段?我正在寻找这样的东西
foreach ($something as $key) {
...
}
首先使用内置 HH\Shapes::toDict
转换为 dict
然后迭代:
foreach(HH\Shapes::toDict($something) as $k => $v) {
// ...
}