Swift 4 is a type-safe language which means if a part of your code expects a String, you can’t pass it an Int by mistake. As Swift 4 is type-safe, it performs type-checks when compiling your code and flags any mismatched types as errors.
import Cocoa var myVar = 42 myVar = "This is a sample String" print(myVar)
Playground execution failed: error: :6:6: error: cannot assign to ‘let’ value ‘myVar’
myVar = “This is a sample String”
When we compile the above program, it produces the following compile time error.