Skip to content

Instantly share code, notes, and snippets.

@ReneSac
Last active January 4, 2016 17:59
Show Gist options
  • Save ReneSac/a638e1f9d3da866e1f55 to your computer and use it in GitHub Desktop.
Save ReneSac/a638e1f9d3da866e1f55 to your computer and use it in GitHub Desktop.
proc optarg(x:int, y:int=0):int = x + y
proc optarg2(x:int, y:int=0, z:int=0):int = x + y - z
proc singlearg(x:int):int = 20*x
echo optarg 1, optarg 2, singlearg 2 # prints 1240
echo optarg2 1, optarg2 2, singlearg 2 # prints 1240
echo optarg2(1, optarg2(2, singlearg 2)) # prints 43
echo 1.optarg 2.optarg, singlearg 2 # prints 340
echo 1.optarg2 2.optarg2, singlearg 2 # prints 340
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment