Day 1 – Words & Numbers – 100 Days of SwiftUI

Last modified date

Comments: 0

Day 1 – Words & Numbers – 100 Days of SwiftUI

Welcome to the notes from my first day of 100 Days of SwiftUI. In the first lesson I learnt:

  • Mutable and Immutable variables,
  • Strings,
  • Whole Numbers and
  • Decimals

A few things stood out to me in the Decimals section.

First thing is that you are not allowed to add Ints and Decimals:

var x = 1
x = 2

var a = 0.1
a = 0.2

var h = a + x // Cannot merge these two types.
// Instead cast them into one type:
var h = Double(x) + a

(Extract from lines 7 through 15 in playground file.)

And you are not allowed to change the type of a variable during its lifespan.

var stringAndInt = "Hello World"
stringAndInt = 7
// We cannot change types during a variables life span even if it is mutable.

(Extract from lines 17 through 19 in playground file.)

Thank you for checking in! 99 more days to go!
Download playground file

dylan

Share

Leave a Reply

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

Post comment