Swift can infer and add sugar a lot, so why in init, it can't infer `value = value` as `self.value = value`?

I can appreciate the desire to not have the weird redundancy that languages often have with Class init functions. That said, value = value reads as a mistake to me.

What I'd love is a way to say "If this init declaration mentions its property symbols in the parameter list, just set them."

Maybe @prop?

Class Foo {
   let bar: Int
   let fum: Int 

  init(_ bar: @prop, fumbled: Int ) {
   self.fum = fumbled * 3
  }
}

Such that var x = Foo(2,4) yields x.bar == 2 and x.fum == 12

2 Likes