Module 3 · Lesson 29 min
var, target-typed new, and init
Three small conveniences you'll read constantly. var infers the type on the left from the right, like TS const without an annotation; the team uses it freely where the type is obvious from the initializer. Target-typed new goes the other way: when the type is already stated, you can write new() and let the compiler fill it in. And init accessors make a property settable only during object construction, which is how you get immutability without a giant constructor.
Try it yourself
Recall
What init buys you
Small idea, stated precisely.
What does an init accessor let you do that a set accessor does not, and why does the domain use it?