Programming in Swift 路 Switch Statements | Ray Wenderlich


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5994-programming-in-swift/lessons/15

I have two questions in this episodes around 3:20 moment,

Why I set a condition case _ where number > .max / 2:
for checking the number is big enough?

I set a constant let number = Int.max before run switch function,
but why I don鈥檛 need to add Int before .max in the case _ where number > .max / 2:

I tried add Int in front of .max, still works.

Thanks for replying my question 49%20PM beforehand.

@domalu You use the wildcard pattern in this case (pun intended) to check that each and every number which enters the switch statement is actually big enough after all to be considered very large indeed. max is a static type property for Int, so you actually need to use the class name in order to call it instead of an instance of the class after all:

https://developer.apple.com/documentation/swift/int/1540171-max

Please let me know if you have any other questions or issues about the whole thing when you get a chance. Thank you!