Swift has this feature already, it is quite popular I belief, so you may draw some inspiration from it.
It works for static members of classes, that return the same type as well as for enums.
class Fruit {
static var apple = Fruit(name: "apple");
static var banana = Fruit(name: "banana");
var name: String;
init(name: String) {
self.name = name;
}
}
func printFruit(fruit: Fruit) {
print(fruit.name);
}
// .banana is here inferred as Fruit.banana
printFruit(fruit: .banana);
About: https://github.com/munificent/ui-as-code/blob/master/ideas/implicit-enums.md
Swift has this feature already, it is quite popular I belief, so you may draw some inspiration from it.
It works for static members of classes, that return the same type as well as for enums.