Creates a new instance from the given integer.
- Xcode 9.0+
- Swift Standard Library
A value to convert to this type of integer. The value passed as
sourcemust be representable in this type.
Use this initializer to convert from another integer type when you know the value is within the bounds of this type. Passing a value that can’t be represented in this type results in a runtime error.
In the following example, the constant
y is successfully created from
Int instance with a value of
100. Because the
Int8 type can represent
127 at maximum, the attempt to create
z with a value of
1000 results in a runtime error.