root@coding-prodigies:~# โ–Š
// lesson 2 of 11 ยท 14 min

Syntax and types

โš‘ Report an issue with this lesson
let name = "Ada"          // constant
var age = 28                 // variable
let price: Double = 29.99

print("\(name) is \(age) years old")

let for constants, var for variables -- Swift strongly favors let by default, similar to Kotlin's val.

Try it yourself

Exercise: Declare a let name and var age, then print them with string interpolation.
Expected output: open-ended โ€” there's no single correct output here, just get your code running without errors.
swift
Output

      
    

Run your code and get it working before marking this lesson complete.

// free preview

8 more lessons โ€” including Capstone project: a course catalog โ€” plus a certificate are waiting.

Unlock the full course โ€” $149.99