4 ms·
He covers type inference too, which is much more painful not having: Animal animal = new Animal(); val animal = Animal(); Swift also doesn't need the semicol
by melling 10y ago
He covers type inference too, which is much more painful not having:
Animal animal = new Animal();
val animal = Animal();
Swift also doesn't need the semicolons. You can also omit the () in if and switch statements. It all adds up to a lot unnecessary noise. The immutability of let is really nice too.
let animal = Animal()
In Swift I don't bother adding the type for Strings, Bools or Ints:
let foo = "Hello world"
let answer = 42
var isDone = false
if isDone {
print("Correct: \(answer)")
} else {
print("Wrong answer!")
}