Type inference by the compiler
📖 Scenario: Imagine you are creating a simple Swift program to store information about a fruit basket. You want to use the compiler's ability to guess the type of your variables automatically, so you don't have to write the type explicitly.
🎯 Goal: Build a Swift program that uses type inference to create variables for fruit names and quantities, then prints them.
📋 What You'll Learn
Create variables using type inference with exact names and values
Add a constant to hold the total number of fruits
Use a for loop to print each fruit and its quantity
Print the total number of fruits at the end
💡 Why This Matters
🌍 Real World
Type inference helps programmers write cleaner and shorter code by letting the compiler figure out data types automatically.
💼 Career
Understanding type inference is important for Swift developers to write efficient and readable code, especially in app development.
Progress0 / 4 steps