• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • WordPress
    • WordPress Website Design Process
    • WordPress Tutorials
    • WPplaces – Managed WordPress Hosting
    • Website Design Terms of Service
  • Content Production
  • IT Services
    • Remote Support
  • Open Source
  • Apple
  • SpaceX
  • Starlink
  • Tesla

KennethJackson.Tech

Web and iOS Developer - Systems Integrator and Administrator

  • Facebook
  • Twitter
  • YouTube
  • GitHub
  • Home
  • Kenneth Jackson
  • Showcase
  • Testimonials
  • Contact
  • Inventory
  • My Account
    • Cart
    • Client Portal
    • Payments
You are here: Home / Apple / Swift / Intermediate Swift – Chapter 2.2 Functions

November 4, 2018

Intermediate Swift – Chapter 2.2 Functions

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 this 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

Reader Interactions

Leave a Reply Cancel reply

Primary Sidebar

Recent Posts

  • LiDAR Test Post March 1, 2021
  • High Flight – Pilot Officer John Gillespie Magee Jr. December 11, 2020
  • John Lennon – October 9, 1940 – December 8, 1980 December 8, 2020
  • Remembering Pearl Harbor December 7, 2020
  • Apple Event – One More Thing – Apple Silicon MacBook Pro, MacBook Air, and Mac mini November 10, 2020
  • Training Day – CoreML, CreateML and Object Detection November 8, 2020
  • Time for Holiday Marketing Campaigns November 6, 2020
  • Workflow – Think Different November 4, 2020
  • Workflow – Donut-shaped C Code November 2, 2020
  • Workflow – iPhone 12 Review – Marques Brownlee November 1, 2020

Categories

  • Apple
    • Augmented Reality
    • Events
    • iPhone 12
    • iPhone 6
    • iPhone 6 Plus
    • Mac
    • Machine Learning
    • Swift
  • Best Practices
  • Client Work
  • Design
  • eCommerce
  • Electronics
  • Email List Management
  • Events
  • Facebook
  • Galleries
  • Google
  • History
  • Latest News
  • Local Search
  • Made In Amarillo
  • Microsoft
  • My Gear
  • NGINX
  • One More Thing
  • Pay-Per-Click (PPC)
  • Photography
  • Projects
    • Christine
  • Rants
  • Recipes
  • Search Engine Optimization (SEO)
  • SpaceX
  • Tesla
  • The Humor File
  • Twitter
  • WooCommerce
  • WordPress
  • Workflow
  • Yahoo
  • YouTube

Subscribe to KennethJackson.Tech

Kenneth Jackson

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

Contact Kenneth

Footer

Follow Me

  • Facebook
  • Twitter
  • YouTube
  • GitHub
  • Discord
  • Contact Us

Administrative

  • Payments
  • Advertisements
  • Privacy Policy
  • Terms of Service
  • Terms and Conditions
  • Website Design Terms of Service

My Work

  • WPplaces Managed WordPress
  • SpaceX Status Report
  • AmaKit – Swift Developer Group

Copyright © Kenneth Jackson

Designed by Kenneth Jackson in Amarillo, Texas

Powered by WPplaces

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.