Skip to content

Instantly share code, notes, and snippets.

@benshine
Created December 19, 2019 03:14
Show Gist options
  • Save benshine/f5590a3e275aa9444247333020546c5b to your computer and use it in GitHub Desktop.
Save benshine/f5590a3e275aa9444247333020546c5b to your computer and use it in GitHub Desktop.
<?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