func next() - > members?
}
var items = [ 10 , 20 , 30 ].generate()
while let x = items.next() {
println(x)
}
for lists in map([ 1 , 2 , 3 ], {i in i* 5 }) {
println(lists)
}
println([ 100 , 200 , 300 ])
println(map([ 1 , 2 , 3 ], {i in i* 10 }))
When we run the above program using playground, we get the following result:
10
20
30
5
10
15
[100, 200, 300]
[10, 20, 30]
Adding Protocol Conformance with an Extension
Existing type can be adopted and conformed to a new protocol by making use of
extensions. New properties, methods and subscripts can be added to existing types with
the help of extensions.
protocol AgeClasificationProtocol {
var age: Int { get }
func agetype() - > String
}
class Person {