我今天开始学习hacklang,现在我有点卡在形状上:http: //docs.hhvm.com/manual/en/hack.shapes.php
我理解形状的概念,它似乎对我很有用,但我无法理解为什么例如这段代码不会抛出任何错误:
<?hh
type Point2D = shape('x' => int, 'y' => int);
function dotProduct(Point2D $a, Point2D $b): int {
return $a['x'] * $b['x'] + $a['y'] * $b['y'];
}
function main_sse(): void {
echo dotProduct(shape('x' => 3, 'y' => 'this should cause an fatal error?'), shape('x' => 4, 'y' => 4));
}
main_sse();
Run Code Online (Sandbox Code Playgroud)
'y'键定义为整数,但是当我传递一个字符串时,不会显示错误.谢谢你的帮助 :)