In certain situations, it is difficult to determine the return type of a function prior to its call. In that situation we use the ‘mixed’ type.
Example:
Example:
<?hh function add(mixed $val): mixed { if (is_array($val) || $val instanceof Vector) { $sum = 0; foreach ($val as $val) { $sum += $val; } return $sum; } return $val; }
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.