• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

KennethJackson.Tech

Audio & Video Production in Amarillo, Texas

  • Home
  • For Musicians
    • Mobile Studio Gear List
    • Stage/Mixer Routing
    • Cartage Services
  • Shop
  • Galleries
  • About
  • Contact
  • Account
    • Cart
    • Payments
You are here: Home / Apple / Swift / Intermediate Swift – Chapter 2.2 Functions

Intermediate Swift – Chapter 2.2 Functions

November 4, 2018 by Kenneth Jackson Leave a Comment

import UIKit

func displayPi() {
    print("3.1415926535")
}

displayPi()

//Parameters

func triple(value: Int) {
    let result = value * 3
    print("If you multiply \(value) by 3, you'll get \(result).")
}

triple(value: 10)

func multiply(firstNumber: Int, secondNumber: Int) {
    let result = firstNumber * secondNumber
    print("The result is \(result).")
}

multiply(firstNumber: 7, secondNumber: 8)

//Argument Labels

func sayHello(to firstPerson: String, and SecondPerson: String) {
    print("Hello, \(firstPerson) and \(SecondPerson).")
}

sayHello(to: "Jancy", and: "Yvonne")

//Default Parameters

func display(teamName: String, score: Int = 0) {
    print("\(teamName): \(score)")
}

display(teamName: "Wombats", score: 100)
display(teamName: "Warriors")

//Return Values

func multiply1(firstNumber: Int, secondNumber: Int) -> Int {
    let result = firstNumber * secondNumber
    return result
}

print(multiply1(firstNumber: 7, secondNumber: 8))

let myResult = multiply1(firstNumber: 5, secondNumber: 5)

print("5 * 5 is \(myResult)")

print("5 * 2 is \(multiply1(firstNumber: 5, secondNumber: 2))")

Share this:

  • Share
  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to print (Opens in new window)
  • Click to email a link to a friend (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Skype (Opens in new window)
  • Click to share on Telegram (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)

Filed Under: Swift Tagged With: Amarillo, Swift 4.2, Texas

Leave a Reply Cancel reply

  • Facebook
  • GitHub
  • Twitter
  • YouTube

Upcoming Shows

Nothing from March 22, 2023 to April 22, 2023.

Product categories

  • Musical Instruments
  • Pro Audio
  • Services
  • Electronic Components

Recent Posts

  • Cowtown Opry Buckaroos – Canyon, Texas – October 8, 2022 – Full Show November 7, 2022
  • Danny Freeze & Dr. T – Songwriters in the Canyon – July 13, 2022 – Full Show (Sorta) November 7, 2022
  • Michael D Coon – Pampa, Texas – September 30, 2022 October 18, 2022
  • Songwriters in the Round – Chalice Abbey – July 16, 2022 October 4, 2022
  • Keitha Jones – Grandma – Songwriters in the Canyon – June 15, 2022 September 29, 2022

Kenneth Jackson

(806) 374-2323
Please leave a voice or text message.

Contact Kenneth

  • Facebook
  • Twitter
  • YouTube
  • GitHub
  • Discord
  • Contact Us
  • Payments
  • Advertisements
  • Privacy Policy
  • Terms of Service
  • Terms and Conditions
  • Connections.Digital – IT Services
  • WPplaces – Managed WordPress
  • AmaKit – Swift Developer Group

Copyright © Kenneth Jackson

Designed by Kenneth Jackson in Amarillo, Texas

Powered by WPplaces