Swift - Introduction Constants

Introduction

In Swift, you create a constant using the let keyword:

Demo

let radius = 3.45
let numOfColumns = 5
let myName = "hi"

print(radius)//from www .  j a va2s.c o m
print(numOfColumns)
print(myName)

Result

There is no need to specify the data type.

The data types are inferred automatically.

Here, radius is a Double, numOfColumns is an Int , myName is a String.

Related Topics