Simple Swift Template

Hloni
799 views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Welcome!

This Swift template gives an example of using Collections

1
2
3
4
5
6
7
8
// Collecitons
/*#################################*/
// Create an array of all odd squares of 1-20 using map and filter
let oneToTen = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
var oddSquares = oneToTen.map { $0 * $0 }.filter { $0 % 2 != 0 }
print(oddSquares)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Advanced usage

If you want a more complex example (external libraries, viewers...), use the Advanced Swift template

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content