Created
July 5, 2015 08:47
-
-
Save masakid/7f0eebf1676fe7af17e3 to your computer and use it in GitHub Desktop.
[swift]ジェネリクス関数
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
func makeArray<T>(items:T...) -> [T]{ | |
var array = [T]() | |
for item in items { | |
array += [item] | |
} | |
return array | |
} | |
let nums = makeArray(3,5,7,9) | |
let colors = makeArray("red","yellow","blue") | |
println(nums) | |
println(colors) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment