Swift 4 – Range Operator

preview_player
Показать описание
Swift 4 – Range Operator

Lecture By: Mr. Ashish Sharma, Tutorials Point India Private Limited
Рекомендации по теме
Комментарии
Автор

I'm trying to use a closed range for a computed property in an enum but it's not working. Like this ...
enum example {
case a, b, c
var index : 1...3
switch self {
case .a : return 1
case .b : return 2
case .c : return 3
}
}


but this doesn't compile. What am I doing wrong ? I'm trying to use a closed range as a type to help enforce strong typing and reduce potential for bugs. Thank you.

hv