Alias in Swift

Swift code to create alias. Alias will help you to create data types of a new custom name.

Source code :


//Creating an Alias for 8 Bit Unsigned Integer

typealias IP = UInt8

print(IP.max) //Prints the maximum value of 8 Bit unsigned integer which is 255


//Creating an Alias for 8 Bit Unsigned Integer

typealias Integer16Bit = Int16

print(Integer16Bit.min) //Prints the mminimum value of 16 Bit unsigned integer which is -32768


Output :

255
-32768

Output :


                

Comments :