Created
December 19, 2019 03:14
-
-
Save benshine/f5590a3e275aa9444247333020546c5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?hh | |
function pass_by_value(shape('key' => string) $args ): void { | |
$args['key'] = "modified"; | |
} | |
function pass_by_reference(inout shape('key' => string) $args ): void { | |
$args['key'] = "modified"; | |
} | |
<<__EntryPoint>> | |
function will_it_change() : void { | |
$s = shape('key' => 'original'); | |
echo("in outer un, have key ". $s['key']."\n"); | |
pass_by_value($s); | |
echo("in outer un, now have key ". $s['key']."\n\n"); | |
$t = shape('key' => 'original'); | |
echo("with inout: in outer un, have key ". $t['key']."\n"); | |
pass_by_reference(inout $t); | |
echo("in outer un, now have key ". $t['key']."\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment