Optionals and nil in Swift

Optionals: Optional in swift represents that a value may or may not exist. Example: Though we have explicitly assigned value in name variable, in real life app, we may take input from user. User may forget to enter the name. In that case, this name variable will by empty. If value is not exist in … Read more

Data Types in Swift Programming

Swift is a type-safe language, meaning that every variable or constant must have a specific type. Data type cannot be changed once it’s set. Swift has a variety of data types that we can use to define variables and constants. Some of the fundamental data types in Swift are: Integers Integers are whole numbers with no … Read more

Swift Variables and Constants

Swift Variables In Swift, var is used to create a variable. Variable means we can change its value anytime we want. Here is an example: You can print and see the value of the name variable like this: We will get John in the output area. Assign a value to a variable We can create … Read more

Swift Hello world!

Swift is a modern, safe, fast and powerful programming language developed by Apple. It has a clean and expressive syntax that makes it easy to read and write code. We can write a simple Hello World program like this: That’s it. It will print Hello World! in the console. Write and Run Swift Code There … Read more