Learn SwiftUI (Day 2/100)

Learn SwiftUI (Day 2/100)

Swift

  • Boolean
  • String interpolation
  • Project: convert C to F
import Cocoa // boolean
var gameOver = false
print(gameOver)
gameOver.toggle()
print(gameOver) // join string
var name = "john" + " " + "doe"
// use string interpolation
let firstName = "john"
let lastName = "doe"
let age = 25
let fullName = "full name is \(firstName) \(lastName), and he is \(age) years old" // check point
/*
Creates a constant holding any temperature in Celsius.
Converts it to Fahrenheit by multiplying by 9, dividing by 5, then adding 32.
Prints the result for the user, showing both the Celsius and Fahrenheit values.
*/ let tempC = 21
let tempF = tempC * 9 / 5 + 32
print("\(tempC) Celsius is \(tempF) in Fahrenheit")
Enter fullscreen mode
Exit fullscreen mode

Discover more from Coursity

Subscribe to get the latest posts to your email.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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