I started learning hacklang today, and now I'm a bit stuck in forms: http://docs.hhvm.com/manual/en/hack.shapes.php
I understand the concept of shapes and it seems really useful to me, but I canβt understand why, for example, this code does not cause any error:
<?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();
The key 'y' is defined as an integer, but when I pass the string, the error is not displayed. Thanks for the help:)
hhvm hacklang
WebDevHere
source share