Follow Us

This is our first episode learning the new language from Apple, Swift.

This week we take a quick look at the new playground and some language basics like constants, variables, variable types, condition statements, loops, while, switch/case, functions, nested functions, functions as arguments and more.

 

Downloads

Apple HD   Apple SD   Audio MP3

 

var str = "Hello, playground"

let goodbye = "Goodbye everyone"

str = "later"

var number: Double = 5

let label = "Today is the "
let dayNumber = 3
let dayDescription = label + String(dayNumber)

let cars = 35
let trucks = 7
let carSummary = "I Have \(cars) Cars On My Lot"
let otSummary = "I Have \(cars + trucks) total vehicles on my Lot"

var colorArray = ["Red", "Green", "Blue", "Yellow", "Pink"]
colorArray[4]
colorArray[4] = "Cyan"
colorArray[4]

var friendList = [
    "Michelle": "DOL-BLS",
    "Mike": "Mechanic"
]

friendList["Jackie"] = "Enterprise Security"

for (friendName, FriendOccupation) in friendList {
    if friendName == "Jackie" {
        friendName
    } else {
        FriendOccupation
    }
}

for var l=0; l<10; ++l {
    l
}

for l in 0..20 {
    l
}

var n: Int = 2

while n < 100 {
    n = n * 2
}

n = 2
do {
    n = n * 2
} while n < 100


let vegetable = "red pepper"
switch vegetable {
    case "celery":
        let veggie = "You are eating crunchy celery"
    
    case "cucumber", "Watermellon":
        let veggie = "You are eating juicy"
    
    case let x where x.hasSuffix("pepper"):
        let veggie = "Is is a spicy \(x)?"
    
    default:
        let veggie = "Everything is good in soup"
}

func theHello(name: String, dayToday: String) ->String {
    return "Hello \(name), how is yout \(dayToday) going?"
}

theHello("Brian", "Wednesday")

func getTemperatures() -> (Double, Double, Double) {
    return (75.5, 81, 53)
}

getTemperatures()

func addTogether(numbers: Int...) -> Int {
    var sum: Int = 0
    for number in numbers {
        sum += number
    }
    
    return sum
}

addTogether(25,11,28)

addTogether(25,11,28,75,92,36)


func addNested(addValue: Int) -> Int {
    var y = 10
    func add() {
        y += addValue
    }
    add()
    return y
}

addNested(50)

func grade(score: Int) -> String {
    switch score {
        case 93..100:
            return "A"
        case 86..92:
            return "B"
        case 79..86:
            return "C"
        default:
            return "F"
    }
}

func swingGrade(score: Int) -> String {
    switch score {
    case 90..100:
        return "A"
    case 80..89:
        return "B"
    case 70..79:
        return "C"
    default:
        return "F"
    }
}

func setGrade(score: Int, grade: Int -> String) -> String {
    return grade(score)
}

setGrade(90, grade)




var numbers = [12, 7, 10, 25, 35]

numbers

numbers.map({
    (number: Int) -> Int in
    let result = 3 * number
    if result % 2 == 0 {
        return 0
    } else {
        return result
    }
})


numbers

Church Technology Recent Shows

  • Learning Swift Week 2 - TP5 +

    This week we dive into Classes and Structures in Apple's new language called Swift. Downloads Apple HD Apple SD Audio Read More
  • Learning Swift, Apples New Language Basics - TP4 +

    This is our first episode learning the new language from Apple, Swift. This week we take a quick look at Read More
  • Programming Basics #3 - Episode 3 +

    This is our last week covering programming basics. Next week we jump right into Python. If you have not watched Read More
  • Programming Basics #2 - Episode 2 +

    This is week #2 of the programming basics. We are covering the basics of computer programming so that when we Read More
  • Programming Basics #1 - Episode 1 +

    In our first week we are starting from the very beginning of programming. The first 3 weeks start from the Read More
  • 1

Contact The Program

email: theprogram@tech-zen.tv
twitter: @tztheprogram
phone: 424-262-5348

Twitter - Home