Last active
August 10, 2018 02:28
-
-
Save mildocjr/9d4fa6c97ab9ce9d94a3d091f76ceb62 to your computer and use it in GitHub Desktop.
compiler-hate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This does not work | |
var myString // we get a compiler error | |
// This is how it should be written | |
var myLastName: String | |
var myAge: Int | |
// You can, and should, use the type declaration with initial values | |
// so you know exactly what the value should be later on | |
var totalMiles: Double = 5.0 | |
var glassesOfWater: Float = 7.0 | |
// Warning: If you use a decimal value without using a type | |
// declaration it will default to a Double type in Swift | |
var glassesOfWater = 7.0 // same as var glassesOfWater: Double = 7.0 | |
// constants also can use type declaration; what type should this | |
// be? | |
let starDateBirthDay = 47457.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment