Ad space (banner)
๐ŸฆSwift Lessons
Lesson 13 / 68

Using the Standard Library

In this lesson you will learn about handy features that ship with the Swift standard library, so you know what you do not have to build yourself. This is for anyone searching for "Swift standard library how to use".

Convenient string APIs such as .uppercased() and String(repeating:count:) come as standard. The Swift standard library is designed with safety in mind, and simply knowing it makes implementation far easier.

The sample code converts to upper case with "hello".uppercased(), repeats a character with String(repeating: "0", count: 2), and reads the number of elements with [1, 2, 3].count. Having a working knowledge of the string and collection APIs makes you noticeably faster at writing code.

A common stumbling block for beginners is not knowing what the standard library already provides and writing the same logic out at length by hand. Getting into the habit of checking the official documentation for something similar matters.

In real-world development, how well you know the standard library maps directly onto the quality of your code and the speed you write it.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run Swift directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)