by Frank Vernon | Feb 21, 2021 | Optionals, Xcode
// 2 ways to print the highest score… var studentsAndScores = [”Amy”: 88, “James”: 55, “Helen”: 99] func highestScore(scores: [String: Int]) { //OPTION 1 BELOW HERE! let a = studentsAndScores [”Amy”]!...
by Frank Vernon | Feb 19, 2021 | If-Then
This sample code checks to see if a given year is a LEAP year… var aYear = Int.self func isLeap(year: Int) { var leap = “NO” //IF divisible by 4 with no remainders. if year % 4 == 0 { leap = “YES” //Is leap year, unless: } if year % 100...
by Frank Vernon | Feb 19, 2021 | Function
func calculator() { let a = Int(readLine()!)! //First input let b = Int(readLine()!)! //Second input add(n1: a, n2: b) subtract(n1: a, n2: b) multiply(n1: a, n2: b) divide(n1: a, n2: b) } func add(n1: Int,n2: Int) { print(n1 + n2) } add(n1: 3, n2: 4) func subtract(n1:...
by Frank Vernon | Feb 18, 2021 | Random, Xcode
let alphabet =...
by Frank Vernon | Feb 18, 2021 | Array, Random
Way #1: diceImageView1.image = [ #imageLiteral(resourceName: “DiceOne”), #imageLiteral(resourceName: “DiceTwo”), #imageLiteral(resourceName: “DiceThree”), #imageLiteral(resourceName: “DiceFour”),...
Recent Comments