0
0
Swiftprogramming~10 mins

Enum declaration and cases 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 declare an enum named Direction.

Swift
enum [1] {
    case north
    case south
    case east
    case west
}
Drag options to blanks, or click blank then click option'
AMove
Bdirection
CDirection
DDirections
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase for enum name
Using plural form which is not the given enum name
2fill in blank
medium

Complete the code to add a case named 'up' to the enum.

Swift
enum Movement {
    case [1]
    case down
}
Drag options to blanks, or click blank then click option'
Aright
Bleft
Cforward
Dup
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase letters for case names
Choosing a wrong direction name
3fill in blank
hard

Fix the error in the enum case declaration.

Swift
enum Color {
    case [1]
}
Drag options to blanks, or click blank then click option'
Ared
BRED
CRed
DrEd
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase letters for enum cases
Using mixed case which is not standard
4fill in blank
hard

Fill both blanks to declare an enum with two cases: 'spring' and 'fall'.

Swift
enum Season {
    case [1]
    case [2]
}
Drag options to blanks, or click blank then click option'
Aspring
Bsummer
Cfall
Dwinter
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong season names
Using uppercase letters
5fill in blank
hard

Fill all three blanks to declare an enum with cases 'small', 'medium', and 'large'.

Swift
enum Size {
    case [1]
    case [2]
    case [3]
}
Drag options to blanks, or click blank then click option'
Asmall
Bmedium
Clarge
DextraLarge
Attempts:
3 left
💡 Hint
Common Mistakes
Including a case not requested like 'extraLarge'
Using uppercase letters