Back
Close

Simple Swift Template

Hloni
6,440 views

Welcome!

This Swift template gives an example of using Collections

// 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

Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants