Your First iOS App: Coding in Swift

Jul 28 2026 · Swift 6.3, iOS 26, Xcode 26

Lesson 08: Type Inference

Type Inference

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

We’ve now reduced our points(sliderValue:) method to just a few lines of code.

  let difference = abs(target - sliderValue)
  let awardedPoints = 100 - difference
var target = Int.random(in: 1...100)
var score = 0
var round = 1
@State private var alertIsVisible = false
@State private var sliderValue = 50.0
@State private var game = Game()
let roundedValue = Int(sliderValue.rounded())
return 100 - difference
return 100 - abs(target - sliderValue)
100 - abs(target - sliderValue)
See forum comments
Cinema mode Download course materials from Github
Previous: Variables & Constants Next: Conclusion