Swift: Raw{Not}Representable enum

Preconditions: Xcode Version 6.3 (6D532l), Swift 1.2 In Swift An enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within yout code | Enumerations are first-class types in their own right. Use enum to create…

Swift: Madness of Generic Integer

Handling Integers with Swift is not the easiest task. Especially when I need the generic function that can do some work on any kind of Integer. There are 11 Integer types that can be considered as Integers: Int8 UInt8 Int16 UInt16 Int32 UInt32 Int64 UInt64 Int UInt Bit (I'll skip…

Swift Integer Overflow issue

Recently I had this conversation on bugreport.apple.com with Apple engineer. I filled report that application will crash when initialized with bigger value than can be stored in initialized object, as a respond “determined that this issue behaves as intended. UInt8(u) is a checked conversion. 773162 is not…

Swift: Bit type with Generics

Note to myself: Some informations here may be outdated due to lated changes in Swift language. It might be surprising that High Level language like Swift have dedicated Bit type. It’s enum actually. Integer actually. enum Bit : Int, RandomAccessIndexType, Reflectable, IntegerArithmeticType { case Zero case One (...) } If I ever think…