100 Days of SwiftUI Day 15

100 Days of SwiftUI – Day 15 – Consolidation

It’s day 15 of the 100 Days of SwiftUI! After going through the first 14 days and learning the fundamentals of Swift, day 15 focused on recapping everything we’ve learned in rapid succession. Instead of going through everything we’ve learned again, like using optionals, I’ll be writing some examples on the subjects I’ve found difficult.

Ternary condition operator in SwiftUI

With the ternary conditional operator, we can quickly check a condition and put a resulting value in a variable. They follow the WTF acronym: what (condition), true (if the condition is true) and false (if the condition is false).

let age = 21
let canVote = age >= 18 ? "Yes" : "No"

print(canVote)

Closures

Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages.

The Swift Programming Language
let team = ["Darryl", "Jace", "Eliza", "Maine"]

var myTeam = team.filter({name in name.hasPrefix("E")})

print(myTeam)

Tomorrow, we’ll be starting our very first SwiftUI project. It’s time to recharge and get ready for a challenge, as the difficulty will ramp up from here. Onwards we go!

Darryl

Hi! My name is Darryl and this is my personal blog where I write about my journey as I learn programming! You'll also find articles about other things that interest me including games, tech and anime.

Post navigation

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

100 Days of SwiftUI – Day 97

100 Days of SwiftUI – Day 35

100 Days of SwiftUI – Day 57

100 Days of SwiftUI – Day 60