Implicit type name inference when using constructor to build parameter value

How about this feature which I've seen in C++:

struct Something {
  var a: Int
  var b: Int
}

func test(_ something: Something) {
 // ...
}

Instead of

test(Something(a: 1, b: 2))

wouldn't it be nice to write

test({a: 1, b: 2})

or something along those lines?

you can write test(.init(a: 1, b: 2)) today

4 Likes

Oh, you're right. This seems good enough.

Terms of Service

Privacy Policy

Cookie Policy