[Solved] How to make a variable in Swift 5? [closed]


As per the Swift Programming Language you do not need to define the Data Type before the variable name as per other OOP languages like Java.

The following is how you create a variable in Swift.

var name = "Name"

The var keywords takes your data which is “Name” and automatically assign a data type for your variable.

If you are to store a int, you can go as follows,

var number = 1

And it’s not mandatory to have ‘;’ signs after a line in Swift as in Java.

Also if you want to create a variable that is not mutable (cannot be changed as per the final keyword in Java) then instead of the ‘var’ keyword you use the keyword ‘let’

let name = "Name"

3

solved How to make a variable in Swift 5? [closed]