Published Jun 15 2021
This tutorial belongs to the Swift series
Suppose you have an array in Swift, like this:
let items = [1, 2, 3]
and you want to get a random number out of it.
The Array data type provides the randomElement()
function that returns an Element?
:
let item = items.randomElement()
I wrote an entire book on this topic 👇
© 2023 Flavio Copes
using
Notion to Site.
Follow on Twitter
Solopreneur? Wannabe? Adventure awaits