Skip to content

Instantly share code, notes, and snippets.

@dfinke
Created October 21, 2021 14:07
Show Gist options
  • Save dfinke/2a2d9cc0b757cd0973d479a1625ad867 to your computer and use it in GitHub Desktop.
Save dfinke/2a2d9cc0b757cd0973d479a1625ad867 to your computer and use it in GitHub Desktop.
function add ($a, $b) {
$a + $b
}
function subtract ($a, $b) {
$a - $b
}
$a, $b = 4, 5
$fn = if($a -gt $b) {'subtract'} else {'add'}
&$fn $a $b # 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment