{infiniteZest} // Articles. Tutorials. Utilities.
Categories Test: Swift - Type Aliases

2. How can type alias a tuple that represents x and y of a point - both x and y have a decimal part to their numbers?

 typealias Int = (Int, Int) [CORRECT ANSWER] typealias Point = (Float, Float) [CORRECT ANSWER] typealias PrecisePoint = (Double, Double) [CORRECT ANSWER] typealias Point = (x: Float, y: Float)

Results
Correct Answer: typealias Point = (Float, Float); typealias PrecisePoint = (Double, Double); typealias Point = (x: Float, y: Float);
Explanation
First option is a circular reference to Int - would result in an error. Since either Float or Double can represent decimal numbers, rest of the type aliases would work. In the last example, the tuple has named parameters - that’s fine.
Take the Test
Take the complete test on this topic. You will be able to review answers to questions and get a test score.

Take the Test

Question 2 of 5 APPLE Swift - Type Aliases Tags: This article talks about using a different name to refer to a type, by using typealias. Tags: Test on using Type Aliases in Swift. Tags: Test on using Type Aliases in Swift. Tags: This article discusses the boolean types in Swift and contrasts with how these types are used in C and Objective-C. Tags: Test on Boolean Types in Swift. Tags: This article goes through the usage of various integer types in Swift (including Int and UInt). Tags: Test on Integer types in Swift.