Variables

Variable Declaration in Swift

Used to declare a variable which holds a value.


Syntax
//implicitly typed
var variableName = value
//explicitly typed
var explicitVariableName: DataType = value

Notes

Variables can be implicitly or explicitly typed. Variables can be changed after values are set.

Variables must either contain a value or nil.


Example
var name = "Anthony"
var length: Integer = 5

< Import Module   |   Constants >

© 2018 SyntaxDB. All Rights Reserved.