In this code:
enum Dog {
case Snoopy
case Lassie
case Scooby
}
let offset = 3
let dogRange = [ Dog.Snoopy : ( offset + 1 ... 5 ), Dog.Lassie : ( 6 ... 10 ), Dog.Scooby : ( 11 ... 15 ) ]
I do not get an error in Swift. However, if I encapsulate in a class
enum Dog {
case Snoopy
case Lassie
case Scooby
}
class animal {
let offset = 3
let dogRange = [ Dog.Snoopy : ( offset + 1 ... 5 ), Dog.Lassie : ( 6 ... 10 ), Dog.Scooby : ( 11 ... 15 ) ]
}
I get the error Instance member "offset" cannot be used on type "animal". I've tried changing to self.offset, but I then I get the error Use of unresolved identifier "self". Why, and how can I use a computed range in a dictionary in a class?
Thanks in advance!