Skip to content

Instantly share code, notes, and snippets.

@yostane
Created November 8, 2017 13:38
Show Gist options
  • Select an option

  • Save yostane/1a2a0eb5dd8fe39311c16eb9328c81de to your computer and use it in GitHub Desktop.

Select an option

Save yostane/1a2a0eb5dd8fe39311c16eb9328c81de to your computer and use it in GitHub Desktop.
swift variables
//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