Created
November 8, 2017 13:38
-
-
Save yostane/1a2a0eb5dd8fe39311c16eb9328c81de to your computer and use it in GitHub Desktop.
swift variables
This file contains hidden or 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
| //Declaring variables in swift | |
| var year = 2017 | |
| //swift infers the type of the variables | |
| var text = "Hello" | |
| //the compiler then sets the type of "text" to "string" | |
| //this code will fail during compilation | |
| //text = 2 | |
| //printing variables | |
| print(year); | |
| print(text); | |
| //please note thet we end statemetns using a new line | |
| //we can also specify the type during declaration | |
| var month:Int = 11 | |
| var dateText:string | |
| dateText = 25 + "/" + month + "/" + year | |
| print(dateText) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment