DEV Community

Opeyemi Noah
Opeyemi Noah

Posted on

Day 4/100 day of SwiftUI

Mission log 4.

Type Annotation

Type annotation let us state what data type we want for our variable and constant.

example:

var name: String = "Opeyemi"
Enter fullscreen mode Exit fullscreen mode

Type inference is when swift is able to figure out the data type of a variable or constants, based on value we assign.

example:

var name = "John Doe"
Enter fullscreen mode Exit fullscreen mode

From the snippet above , swift will infer the data type to be String, because we assign text value to the variable.

Top comments (0)