Initializer

init(integerLiteral:)

Creates an instance initialized to the specified integer value.

Declaration

init(integerLiteral value: Int)

Parameters

value

The value to create.

Discussion

Do not call this initializer directly. Instead, initialize a variable or constant using an integer literal. For example:

let x = 23

In this example, the assignment to the x constant calls this integer literal initializer behind the scenes.

See Also

Infrequently Used Functionality

init()

Creates a new value equal to zero.

typealias Int.IntegerLiteralType

A type that represents an integer literal.

func distance(to: Int) -> Int

Returns the distance from this value to the given value, expressed as a stride.

func advanced(by: Int) -> Int

Returns a value that is offset the specified distance from this value.