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 sent to your email.

Leave a Comment

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

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Flutter app development. In recent years, remote work has transformed the traditional office setting, offering unparalleled flexibility and freedom.