You have
typealias Stringish = String
var x: Stringish
func examp() {
x = "yo"
print(x)
}
and you have a zillion Stringish
in your code base. You suddenly realize you need something more like
struct StringBonus {
var value: String
var version: Int
}
typealias Stringish = StringBonus
which is fine but you have to replace “x” everywhere with “x.value”, as it were.
x.value = "yo"
print(x.value)
etc etc etc
var x: Stringish = tedious default value
etc etc etc
It would be incredible if you could still refer to x normally,
x = 69
but also access the “hidden” fields,
x.version = 2
Can anyone think of a way to make a struct “default” to one of the fields, or indeed a trick approach that achieves the same result.
I guess the amazing @resultBuilder
would be impressive but I can’t see a way to have a free-form resultBuilder inline (where the “x” is).
Maybe someone has a way.