0
0
Swiftprogramming~10 mins

Typealias for custom naming in Swift - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a typealias named Age for Int.

Swift
typealias [1] = Int
Drag options to blanks, or click blank then click option'
AInteger
BNumber
CAge
DValue
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase names for typealias which is not a convention.
Trying to assign a value instead of a type.
2fill in blank
medium

Complete the code to create a typealias named Coordinates for a tuple of two Double values.

Swift
typealias [1] = (Double, Double)
Drag options to blanks, or click blank then click option'
ACoordinates
BPosition
CPoint
DLocation
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a name that does not clearly represent a pair of values.
Using a typealias name that is too generic.
3fill in blank
hard

Fix the error in the code by completing the typealias declaration for Text as String.

Swift
typealias [1] = String
Drag options to blanks, or click blank then click option'
AText
Btext
CSTRING
DStr
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase names for typealias which causes style warnings.
Using all uppercase which is not conventional for type names.
4fill in blank
hard

Fill both blanks to create a typealias named CompletionHandler for a closure that takes a Bool and returns Void.

Swift
typealias [1] = ([2]) -> Void
Drag options to blanks, or click blank then click option'
ACompletionHandler
BBool
CInt
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong parameter type in the closure.
Confusing the closure return type with the parameter type.
5fill in blank
hard

Fill all three blanks to create a typealias named JSONDictionary for a dictionary with String keys and Any values.

Swift
typealias [1] = [[2]: [3]]
Drag options to blanks, or click blank then click option'
AJSONDictionary
BString
CAny
DInt
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect types for keys or values.
Mixing up keys and values in the dictionary syntax.