Creates an integer from the given floating-point value, if it can be represented exactly.
Required. Default implementations provided.
- Xcode 9.0+
- Swift Standard Library
A floating-point value to convert to an integer.
If the value passed as
source is not representable exactly, the result is
nil. In the following example, the constant
x is successfully created from a value of
21, while the attempt to initialize the constant