Swift·Swift from optionals to SwiftUI

Setup and syntax

Use let, var, types and string interpolation in a Swift playground.

Beginner 12 min read Lesson 1 of 300 Challenge included
What you will be able to do
  • Prefer let by default.
  • Use \(value) for interpolation.
  • Use playgrounds for quick experiments.
  • Follow the Swift API design guidelines.

In plain English

Swift is expressive and type-safe. let declares a constant and var a variable. Type inference is strong; annotate when the type is not obvious. Use interpolation to build strings.

main.swiftSwift
let name = "Ada"
var count = 0
count += 1
print("Hello, \(name)! Count: \(count)")
Your turn

Interpolate a value

Easy

Print "Lesson: CSS" using a title constant.

SWIFT · starter
let title = "CSS"
Check your understanding before moving on.
Knowledge checkQuestion 1

Which keyword declares a constant?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Optionals
Lesson 1 of 300 · 0% of course