Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func x< T >(a: T)
- //Tipos genéricos
- //Se crean con la siguiente estructura:
- class X< T > {}
- class X< T: U > {}
- //Creemos una estructura para poner un ejemplo de tipos.
- struct PackageList {
- var packages: [Package]
- mutating func add(package: Package) {
- packages.append(item)
- }
- mutating func remove() -> Package {
- return packages.removeLast()
- }
- func isCapacityLow() -> Bool {
- return packages.count < 3
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment