Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type annotation missing in pattern in swift 2.0

Tags:

ios

swift

swift2

I get the error "Type annotation missing in pattern" when declaring a variable as follows:

var total

What is type annotation?

like image 234
Pias Avatar asked Sep 19 '15 09:09

Pias


1 Answers

Type annotation is the following:

var total:Int

The ":Int" is the type annotation. This must be used when you don't set a value (thus having an implied type) at the time of declaration.

If you were to define your variable as follows:

var total = 9

You would no longer need to explicitly annotate the type at the time of declaration.

like image 172
ThinkingInBits Avatar answered Oct 22 '22 11:10

ThinkingInBits