Created
November 21, 2022 11:03
-
-
Save EvolvingParty/7e58cdd20adb8e22158ac0c1805f5652 to your computer and use it in GitHub Desktop.
DAY 14. 100 Days of SwiftUI – Hacking with Swift. Checkpoint 9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
/// Write a function that accepts an optional array of integers, and returns one randomly. If the array is missing or empty, return a random number in the range 1 through 100. | |
/// Write this whole thing in one line of code | |
func pickANumber(from: [Int]? = nil) -> Int { | |
from?.randomElement() ?? Int.random(in: 1...100) | |
} | |
let newNuber = pickANumber() | |
print(newNuber) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment