Swift - Variables and Constants

Опубликовано: 22 Март 2026
на канале: AmandeepSingh
36
5

📱 Welcome to my channel - Your Ultimate Destination for iOS Development! 🚀

🔍 Explore the World of iOS Development with Amandeep Singh!

We will cover Data Types in this tutorial :-

In Swift, variables and constants are used to store and reference values. Here's an overview of how to declare and use variables (var) and constants (let)

/*
In Swift, variables and constants are used to store and reference values. Here's an overview of how to declare and use variables (var) and constants (let):

Variables (var):
A variable is a mutable storage location that can hold a value of a particular type. You can change the value of a variable after it's initially set.
*/

var itemsInBasket: Int = 10
itemsInBasket = 11
print("itemsInBasket=", itemsInBasket)
//In the example above, itemsInBasket is declared as a variable of type Int and is initially set to the value 10. Later, its value is changed to 11.



/*
Constants (let):
A constant is an immutable storage location, meaning its value cannot be changed after it's initially set. Constants are declared using the let keyword.*/

let myLearning: String = "Learning Swift!"
print("myLearning=", myLearning)




/*
Type Inference:
Swift has a powerful type inference system, which means you often don't have to explicitly mention the type of a variable or constant. The compiler can often deduce it based on the initial value you provide.
*/

var myVariableWithoutExplicitType = 42 // Swift infers the type as Int
let myConstantWithoutExplicitType = "Hello, Type Inference!" // Swift infers the type as String



/*
Naming Conventions:
When naming variables and constants in Swift, it's common to use camelCase. For example:
*/

var piValue: Double = 3.14

🛠️ Prerequisites:
Basic knowledge of Swift programming
Xcode installed on your machine


🎉 Subscribe now for more videos on iOS development, and join our growing community of awesome enthusiasts! 🚀💙

🔔 Hit the notification bell so you never miss a moment – we've got more informative videos coming your way!

🤝 We value your feedback! Drop a comment below – share your thoughts, ideas, and what you want to see more of. This channel is for YOU! 🗣️💬

🚨 Don't forget to give this video a 👍 LIKE if you enjoyed it – it helps us a ton! Share it with your friends and family to spread the [positive vibes, knowledge, laughter]! 🌐👥

🌟 Thanks for being part of the family. Let's create something extraordinary together! 🌈✨


#Swift #Development #iOS #Xcode #iPhone tutorial for beginners #iOS Development #Swift Programming #App Development #User Interface #Auto Layout #Mobile App Design #UIKit #Mobile Development #Code Tutorial #SubscribeNow #JoinTheCommunity #AmandeepSinghChannel #Variables #Constants #Xcode.