I have always preferred explicitly typed languages, saving a couple of characters by simply declaring a variable as var or let can quickly end up in a game of “Guess who?” or “what” to be more precise.
Its straight forward enough with immediate assignments or when the expected type is clear.
var name = "Foo" //clearly String var street = customer.street //most likely String var customer = Customer(name: "Foo", ...)
However when dealing with complex domain models or business functions with unclear return type the value of strong typing quickly becomes apparent.
var value = contract.amount //Int/UInt/Float/Double/String/...? var customer = contract.customer //String/domain model Customer/...? var amountDue = billingService.calculate(...) //Int/UInt/Float/Double/...?
Continue reading Swift for Beans – var, let and Type Inference