Skip to content

Instantly share code, notes, and snippets.

@sonsongithub
Created May 7, 2016 06:15
Show Gist options
  • Save sonsongithub/3a82044d66890a82f341ee157a9860f1 to your computer and use it in GitHub Desktop.
Save sonsongithub/3a82044d66890a82f341ee157a9860f1 to your computer and use it in GitHub Desktop.
さっきのコード #CodePiece #yidev
protocol Photo {
func getName() -> String
}
struct Facebook: Photo {
func getName() -> String {
return "facebook"
}
}
struct Flickr: Photo {
func getName() -> String {
return "flickr"
}
}
protocol Controller {
func a()->String
}
class ViewController<T: Photo> : Controller {
var array:[T] = []
func a()->String {
return "sounds good"
}
}
let v1: Controller = ViewController<Facebook>.init()
let v2: Controller = ViewController<Flickr>.init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment