07-19-2023, 01:21 AM
My case was a little bit different and it involves enums and optionals. For the simplicity lets define
enum Animal {
case Dog
case Cat
}
func exampleAction(animal: Animal) {}
exampleAction(.Cat)
It will run OK. However as soon as I made the argument optional the error started to appear. So this code won't work:
func exampleAction(animal: Animal?) {}
exampleAction(.Cat)
To make it work I had to add explicit enum name in the method call. So the following code worked again:
exampleAction(Animal.Cat)
enum Animal {
case Dog
case Cat
}
func exampleAction(animal: Animal) {}
exampleAction(.Cat)
It will run OK. However as soon as I made the argument optional the error started to appear. So this code won't work:
func exampleAction(animal: Animal?) {}
exampleAction(.Cat)
To make it work I had to add explicit enum name in the method call. So the following code worked again:
exampleAction(Animal.Cat)