Skip to content

Instantly share code, notes, and snippets.

@masakid
Created July 5, 2015 08:47
Show Gist options
  • Save masakid/7f0eebf1676fe7af17e3 to your computer and use it in GitHub Desktop.
Save masakid/7f0eebf1676fe7af17e3 to your computer and use it in GitHub Desktop.
[swift]ジェネリクス関数
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