Day 2 – Booleans and Strings

100 Days of SwiftUI: Day 2

Wow. What a fantastic lesson. I’m blown away. So many foundational pieces are coming together. I’ve taken notes of the lesson and pulled them into graphs that are handy for me. I’m going to pause and work on the actual Checkpoint 1 next week, but so happy with the progress.

Update:

Finished up the checkpoint on Monday, July 10, 2023. The challenge is to take a temperature in Celsius and convert it to Fahrenheit. Paul gave the formula, and I took a stab at figuring it out without using any hints – other than my notes from the previous two days. My initial code wasn’t pretty:

import UIKit

let celciusTemp = 38

let fTemp = (celciusTemp * 9 / 5 + 32)

print(fTemp)
print(celciusTemp)

I started to watch the hints, and had a suspicion that I should do the number with decimals (as a double), but wasn’t sure how to do that. Watching on through Paul’s video he suggested to make the initial number a double, so I tried that.

import UIKit

let celciusTemp = 38.0

let fTemp = (celciusTemp * 9 / 5 + 32)

Another hint Paul suggested is string interpolation, and I’m guessed that was to show the two temperatures side by side, but I wasn’t sure. I looked online and found an answer. Makes so much more sense.

let celsius = 38.0

let fahrenheit = celsius * 9 / 5 + 32

print("The temp of \(celsius)°C is the same as \(fahrenheit)°F.")

Well, that was a start.


Posted

in

by

Tags: