Skip to content

Instantly share code, notes, and snippets.

@zakky-dev
Created November 1, 2017 05:20
Show Gist options
  • Save zakky-dev/0e44ff447c39d64b1825dd6432b064ab to your computer and use it in GitHub Desktop.
Save zakky-dev/0e44ff447c39d64b1825dd6432b064ab to your computer and use it in GitHub Desktop.
こういうことができるのは嬉しいかもしれない
protocol InitWithIntProtocol {
init(i: Int)
}
class WithInt: InitWithIntProtocol {
required init(i: Int) {
print(i)
}
}
func ff<T: InitWithIntProtocol>(i: Int) -> T {
return T(i: i)
}
let _: WithInt = ff(i: 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment