Skip to content

Instantly share code, notes, and snippets.

@mildocjr
mildocjr / concatstrings1.swift
Created August 10, 2018 02:38
concat-strings
var firstName = "John"
let lastName = "Doe"
let fullName = firstName + " " + lastName
@mildocjr
mildocjr / concatstrings2.swift
Created August 10, 2018 02:39
concat-strings2
let fullName = "John" + " " + "Doe"
@mildocjr
mildocjr / mathmatics1.swift
Last active August 10, 2018 02:42
mathmatics-1
var firstNumber = 1
let secondNumber = 2
firstNumber += secondNumber
// first number is now equal to 3
firstNumber *= secondNumber
// first number is now equal to 6 becuase firstNumber became 3 in
// the last operation and we just multiplied it by 2
@mildocjr
mildocjr / declarevar1.swift
Created August 10, 2018 02:42
declare-var-1
var a: Int
@mildocjr
mildocjr / instantiatevar1.swift
Created August 10, 2018 02:43
instantiate-var-1
a = 125
@mildocjr
mildocjr / optionals1.swift
Created August 10, 2018 02:44
optionals-1
var name: String?
@mildocjr
mildocjr / optionals2.swift
Created August 10, 2018 02:45
optionals-2
var name: String? = "James"
@mildocjr
mildocjr / ternaryoperators1.swift
Created August 10, 2018 02:46
ternary-operators-1
var possibleAge: Int? = 26
let age: Int = possibleAge ?? 0
@mildocjr
mildocjr / ternaryoperators2.swift
Created August 10, 2018 02:46
ternary-operators-2
var possibleAge: Int?
let age: Int = possibleAge ?? 0
var hasCoffee: Bool = true
var madeCup: Bool = false
if hasCoffee {
madeCup = true
}
// madeCup is equal to true