Created
July 5, 2015 08:49
-
-
Save masakid/3ce6ac07c1e25dd91576 to your computer and use it in GitHub Desktop.
[swift]外部引数名#をつければ、シグニチャが同じでも関数作れる
This file contains 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
//外部引数名は add # | |
func calc(#a: Int, #b: Int) -> Int { | |
return a+b | |
} | |
func calc(#c: Int, #d: Int) -> Int { | |
return c+d | |
} | |
func calc(#a: Int, #b: Int, #c: Int) -> Int { | |
return a+b+c | |
} | |
var ans1 = calc(a: 2, b: 3) | |
var ans2 = calc(c: 2, d: 4) | |
var ans3 = calc(a: 2, b: 3, c: 7) | |
println(ans1) | |
println(ans2) | |
println(ans3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment