Int
struct Int : SignedInteger, Comparable, Equatable
-
Creates a signed integer from
PerlScalar
. Throws ifsv
does not contain a signed integer.let i = try Int(PerlScalar(100)) // i == 100 let i = try Int(PerlScalar("100")) // i == 100 let i = try Int(PerlScalar(42.5)) // i == 42 let i = try Int(PerlScalar()) // throws let i = try Int(PerlScalar("")) // throws let i = try Int(PerlScalar("any")) // throws let i = try Int(PerlScalar("50sec")) // throws let i = try Int(PerlScalar("10000000000000000000")) // throws let i = try Int(PerlScalar("20000000000000000000")) // throws let i = try Int(PerlScalar("-10")) // i == -10 let i = try Int(PerlScalar("-20000000000000000000")) // throws
Declaration
Swift
public init(_ scalar: PerlScalar) throws
-
Creates a signed integer from
PerlScalar
using Perl macrosSvIV
. Performs no additional checks.let i = Int(unchecked: PerlScalar(100)) // i == 100 let i = Int(unchecked: PerlScalar("100")) // i == 100 let i = Int(unchecked: PerlScalar(42.5)) // i == 42 let i = Int(unchecked: PerlScalar()) // i == 0 let i = Int(unchecked: PerlScalar("")) // i == 0 let i = Int(unchecked: PerlScalar("any")) // i == 0 let i = Int(unchecked: PerlScalar("50sec")) // i == 50 let i = Int(unchecked: PerlScalar("10000000000000000000")) // i == Int(bitPattern: 10000000000000000000) let i = Int(unchecked: PerlScalar("20000000000000000000")) // i == Int(bitPattern: UInt.max) let i = Int(unchecked: PerlScalar("-10")) // i == -10 let i = Int(unchecked: PerlScalar("-20000000000000000000")) // i == Int.min
Declaration
Swift
public init(unchecked scalar: PerlScalar)