SlideShare a Scribd company logo
1 of 31
Download to read offline
Introduction to Swift
Lecture 02
Jonathan R. Engelsma, Ph.D.
TOPICS
• Swift Language Overview
• Our first program!
• Variables and constants
• Strings
• CollectionTypes
• Control Flow
• Functions
THE SWIFT PROGRAMMING
LANGUAGE
• A surprise introduced by Apple @ WWDC in June 2014.
• An industrial-quality systems programming language that is as
expressive and enjoyable to use as a scripting language.
• Seamless access to existing Cocoa frameworks.
• Successor to legacy Objective-C language, but provides mix-
and-match interoperability with Objective-C code.
WHY A NEW LANGUAGE?
• Easier for new programmers to get up to speed in iOS
development.
• New language was necessary in order to ensure compatibility
with existing frameworks.
• Easier to create a new language that feels modern, but still
adapts to Objective-C / C conventions.
SWIFT CHARACTERISTICS
• Compiled: source —> bytecodes, not interpreted.
• Strong and static typing: types are clearly identified and
cannot change (e.g. compiler generates faster safer code).
• Automatic ref counting: objects are automatically freed from
memory when there are no more references.
• Name-spaced: makes our code easier to coexist with other
people’s code.
OUR OBLIGATORY FIRST
PROGRAM!
• a complete Swift program!
• no imports / includes!
• no main program - code
written at global scope
becomes the entry point.
• No semicolons!
CONSTANTS
• Use the “let” statement to define constants.
• values doesn’t need to be known at compile time, but can be
assigned only once.
• value assigned must be the same type as the variable name.
• Types can be implicit or explicit.
VARIABLES
• Use the “var” statement to define variables - values can be
mutated!
• value assigned must be the same type as the variable name.
• Types can be implicit or explicit.
• Type conversion is explicit.
STRINGS
• String type is an ordered collection of Character:“hello, world”
• Bridged to NSString in Objective-C.
• String is a value type: copied when passed to function or
method. (different than NSString in this regard!)
• Strings defined with var can be mutated, strings defined with let
cannot be mutated!
STRINGS
• concatenation: can be accomplished with the + operator
• interpolation: can construct new strings from a mix of values/
expressions. using ().
• Compare using == operator.
• Use the hasPrefix / hasSuffix methods to check how a string
starts/ends.
STRINGS
ARRAYS IN SWIFT
• Arrays store ordered lists of values
• All values in a given array are of the same type
• Values are accessed via methods, properties and subscripting.
ARRAYS
DICTIONARIES IN SWIFT
• Dictionaries store multiple values of the same type
• Each value is associated with a unique key
• Do not have to be in a specified order
• Use just like a real world dictionary: e.g. when you want to
look up the definition of a particular key value
• Keys must be hashable
DICTIONARIES
CONTROL FLOW
• for-in statements:
CONTROL FLOW
• while & do-while statements:
CONTROL FLOW
• if / if-else
SWITCH STATEMENT
• Similar to C syntax, but with some notable differences:
• No need to use break statements!
• No implicit fall through
• Each case must contain at least one executable statement
• Case condition can be scalar, range, or tuple!
• Case condition can actually bind values.
CONTROL FLOW
• switch statement
FUNCTIONS
• Self-contained chunks of code that perform a specific task.
• Functions are typed by the return type and type of the
parameters.
• Swift supports first-class functions, e.g. functions can be passed
as arguments and serve as return values.
• Functions in Swift can be nested.
• Swift functions can have multiple return values.
FUNCTIONS
FUNCTIONS
FUNCTIONS
Returning multiple values from a function:
FUNCTIONS
• So far, all the functions we’ve seen defined what are known as
local parameter names. E.g. they are only referred to in the
function implementation.
• Sometimes its useful to name parameters when you call a
function. These are called external parameter names.
FUNCTIONS
• external parameter names:
FUNCTIONS
• shorthand for external parameter names:
FUNCTIONTYPES
• Variable that refer to functions can be defined:
FUNCTIONTYPES
• Functions can be passed as parameters:
FUNCTIONTYPES
• Functions can be returned from functions:
NESTED FUNCTIONS
• We can rewrite the previous examples with nested funcs:

More Related Content

What's hot

CSP: Huh? And Components
CSP: Huh? And ComponentsCSP: Huh? And Components
CSP: Huh? And Components
Daniel Fagnan
 
Introduction of lambda expression and predicate builder
Introduction of lambda expression and predicate builderIntroduction of lambda expression and predicate builder
Introduction of lambda expression and predicate builder
LearningTech
 
Clojure's take on concurrency
Clojure's take on concurrencyClojure's take on concurrency
Clojure's take on concurrency
yoavrubin
 
A-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
A-Brief-Introduction-To-JAVA8_By_Srimanta_SahuA-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
A-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
Srimanta Sahu
 

What's hot (20)

java token
java tokenjava token
java token
 
Scala’s implicits
Scala’s implicitsScala’s implicits
Scala’s implicits
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
 
Preparing for Scala 3
Preparing for Scala 3Preparing for Scala 3
Preparing for Scala 3
 
Variables in Pharo5
Variables in Pharo5Variables in Pharo5
Variables in Pharo5
 
Diving Into Scala Cats - Semigroups and Monoids
Diving Into Scala Cats - Semigroups and MonoidsDiving Into Scala Cats - Semigroups and Monoids
Diving Into Scala Cats - Semigroups and Monoids
 
CSP: Huh? And Components
CSP: Huh? And ComponentsCSP: Huh? And Components
CSP: Huh? And Components
 
Introduction of lambda expression and predicate builder
Introduction of lambda expression and predicate builderIntroduction of lambda expression and predicate builder
Introduction of lambda expression and predicate builder
 
Java tokens
Java tokensJava tokens
Java tokens
 
Python's dynamic nature (rough slides, November 2004)
Python's dynamic nature (rough slides, November 2004)Python's dynamic nature (rough slides, November 2004)
Python's dynamic nature (rough slides, November 2004)
 
Swift
SwiftSwift
Swift
 
iOS development using Swift - Swift Basics (1)
iOS development using Swift - Swift Basics (1)iOS development using Swift - Swift Basics (1)
iOS development using Swift - Swift Basics (1)
 
Learning typescript
Learning typescriptLearning typescript
Learning typescript
 
What To Leave Implicit
What To Leave ImplicitWhat To Leave Implicit
What To Leave Implicit
 
Introducing TypeScript
Introducing TypeScriptIntroducing TypeScript
Introducing TypeScript
 
iOS development using Swift - Swift Basics (2)
iOS development using Swift - Swift Basics (2)iOS development using Swift - Swift Basics (2)
iOS development using Swift - Swift Basics (2)
 
Clojure's take on concurrency
Clojure's take on concurrencyClojure's take on concurrency
Clojure's take on concurrency
 
A-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
A-Brief-Introduction-To-JAVA8_By_Srimanta_SahuA-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
A-Brief-Introduction-To-JAVA8_By_Srimanta_Sahu
 
Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins
 
New c sharp4_features_part_v
New c sharp4_features_part_vNew c sharp4_features_part_v
New c sharp4_features_part_v
 

Viewers also liked

Никита Корчагин - iOS development information
Никита Корчагин - iOS development informationНикита Корчагин - iOS development information
Никита Корчагин - iOS development information
DataArt
 

Viewers also liked (15)

Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
 
Swift language - A fast overview of some features
Swift language - A fast overview of some featuresSwift language - A fast overview of some features
Swift language - A fast overview of some features
 
IOS Swift language 2nd tutorial
IOS Swift language 2nd tutorialIOS Swift language 2nd tutorial
IOS Swift language 2nd tutorial
 
What Every IT Manager Should Know About Mobile Apps
What Every IT Manager Should Know About Mobile AppsWhat Every IT Manager Should Know About Mobile Apps
What Every IT Manager Should Know About Mobile Apps
 
2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring Conference2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring Conference
 
Mobile Gamification
Mobile GamificationMobile Gamification
Mobile Gamification
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 04)
 
Knowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better BeekeeperKnowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better Beekeeper
 
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
 
Beginning iOS Development with Swift
Beginning iOS Development with SwiftBeginning iOS Development with Swift
Beginning iOS Development with Swift
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
 
Swift Tutorial Part 1. The Complete Guide For Swift Programming Language
Swift Tutorial Part 1. The Complete Guide For Swift Programming LanguageSwift Tutorial Part 1. The Complete Guide For Swift Programming Language
Swift Tutorial Part 1. The Complete Guide For Swift Programming Language
 
Workhop iOS 1: Fundamentos de Swift
Workhop iOS 1: Fundamentos de SwiftWorkhop iOS 1: Fundamentos de Swift
Workhop iOS 1: Fundamentos de Swift
 
Никита Корчагин - iOS development information
Никита Корчагин - iOS development informationНикита Корчагин - iOS development information
Никита Корчагин - iOS development information
 

Similar to iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)

Similar to iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02) (20)

Swift programming language
Swift programming languageSwift programming language
Swift programming language
 
Software Engineering Thailand: Programming with Scala
Software Engineering Thailand: Programming with ScalaSoftware Engineering Thailand: Programming with Scala
Software Engineering Thailand: Programming with Scala
 
Subprogram
SubprogramSubprogram
Subprogram
 
CSE 1201: Structured Programming Language
CSE 1201: Structured Programming LanguageCSE 1201: Structured Programming Language
CSE 1201: Structured Programming Language
 
Java introduction
Java introductionJava introduction
Java introduction
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud Foundry
 
C# basics...
C# basics...C# basics...
C# basics...
 
Apex code (Salesforce)
Apex code (Salesforce)Apex code (Salesforce)
Apex code (Salesforce)
 
2018 12-kube con-ballerinacon
2018 12-kube con-ballerinacon2018 12-kube con-ballerinacon
2018 12-kube con-ballerinacon
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Welcome to New Swift: Library Evolution & LSP Support
Welcome to New Swift: Library Evolution & LSP SupportWelcome to New Swift: Library Evolution & LSP Support
Welcome to New Swift: Library Evolution & LSP Support
 
introduction to server-side scripting
introduction to server-side scriptingintroduction to server-side scripting
introduction to server-side scripting
 
Python Basics.pptx
Python Basics.pptxPython Basics.pptx
Python Basics.pptx
 
Variables and User Input
Variables and User InputVariables and User Input
Variables and User Input
 
Developer’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming language
 
Java script
Java scriptJava script
Java script
 
Python first day
Python first dayPython first day
Python first day
 
Python first day
Python first dayPython first day
Python first day
 
Java script basics
Java script basicsJava script basics
Java script basics
 

More from Jonathan Engelsma

More from Jonathan Engelsma (7)

BIP Hive Scale Program Overview
BIP Hive Scale Program OverviewBIP Hive Scale Program Overview
BIP Hive Scale Program Overview
 
Selling Honey Online
Selling Honey OnlineSelling Honey Online
Selling Honey Online
 
Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc. Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc.
 
Harvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline BeekeepersHarvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline Beekeepers
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 06)
 
So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper? So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper?
 

Recently uploaded

Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Lisi Hocke
 

Recently uploaded (20)

Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024
 
Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with Links
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AI
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements Engineering
 
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
 
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
 
Workshop - Architecting Innovative Graph Applications- GraphSummit Milan
Workshop -  Architecting Innovative Graph Applications- GraphSummit MilanWorkshop -  Architecting Innovative Graph Applications- GraphSummit Milan
Workshop - Architecting Innovative Graph Applications- GraphSummit Milan
 
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
 
Test Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdfTest Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdf
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeCon
 
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdfThe Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
 
Abortion Pill Prices Germiston ](+27832195400*)[ 🏥 Women's Abortion Clinic in...
Abortion Pill Prices Germiston ](+27832195400*)[ 🏥 Women's Abortion Clinic in...Abortion Pill Prices Germiston ](+27832195400*)[ 🏥 Women's Abortion Clinic in...
Abortion Pill Prices Germiston ](+27832195400*)[ 🏥 Women's Abortion Clinic in...
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea Goulet
 
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
 
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
 
From Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIFrom Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST API
 

iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)

  • 1. Introduction to Swift Lecture 02 Jonathan R. Engelsma, Ph.D.
  • 2. TOPICS • Swift Language Overview • Our first program! • Variables and constants • Strings • CollectionTypes • Control Flow • Functions
  • 3. THE SWIFT PROGRAMMING LANGUAGE • A surprise introduced by Apple @ WWDC in June 2014. • An industrial-quality systems programming language that is as expressive and enjoyable to use as a scripting language. • Seamless access to existing Cocoa frameworks. • Successor to legacy Objective-C language, but provides mix- and-match interoperability with Objective-C code.
  • 4. WHY A NEW LANGUAGE? • Easier for new programmers to get up to speed in iOS development. • New language was necessary in order to ensure compatibility with existing frameworks. • Easier to create a new language that feels modern, but still adapts to Objective-C / C conventions.
  • 5. SWIFT CHARACTERISTICS • Compiled: source —> bytecodes, not interpreted. • Strong and static typing: types are clearly identified and cannot change (e.g. compiler generates faster safer code). • Automatic ref counting: objects are automatically freed from memory when there are no more references. • Name-spaced: makes our code easier to coexist with other people’s code.
  • 6. OUR OBLIGATORY FIRST PROGRAM! • a complete Swift program! • no imports / includes! • no main program - code written at global scope becomes the entry point. • No semicolons!
  • 7. CONSTANTS • Use the “let” statement to define constants. • values doesn’t need to be known at compile time, but can be assigned only once. • value assigned must be the same type as the variable name. • Types can be implicit or explicit.
  • 8. VARIABLES • Use the “var” statement to define variables - values can be mutated! • value assigned must be the same type as the variable name. • Types can be implicit or explicit. • Type conversion is explicit.
  • 9. STRINGS • String type is an ordered collection of Character:“hello, world” • Bridged to NSString in Objective-C. • String is a value type: copied when passed to function or method. (different than NSString in this regard!) • Strings defined with var can be mutated, strings defined with let cannot be mutated!
  • 10. STRINGS • concatenation: can be accomplished with the + operator • interpolation: can construct new strings from a mix of values/ expressions. using (). • Compare using == operator. • Use the hasPrefix / hasSuffix methods to check how a string starts/ends.
  • 12. ARRAYS IN SWIFT • Arrays store ordered lists of values • All values in a given array are of the same type • Values are accessed via methods, properties and subscripting.
  • 14. DICTIONARIES IN SWIFT • Dictionaries store multiple values of the same type • Each value is associated with a unique key • Do not have to be in a specified order • Use just like a real world dictionary: e.g. when you want to look up the definition of a particular key value • Keys must be hashable
  • 16. CONTROL FLOW • for-in statements:
  • 17. CONTROL FLOW • while & do-while statements:
  • 18. CONTROL FLOW • if / if-else
  • 19. SWITCH STATEMENT • Similar to C syntax, but with some notable differences: • No need to use break statements! • No implicit fall through • Each case must contain at least one executable statement • Case condition can be scalar, range, or tuple! • Case condition can actually bind values.
  • 21. FUNCTIONS • Self-contained chunks of code that perform a specific task. • Functions are typed by the return type and type of the parameters. • Swift supports first-class functions, e.g. functions can be passed as arguments and serve as return values. • Functions in Swift can be nested. • Swift functions can have multiple return values.
  • 25. FUNCTIONS • So far, all the functions we’ve seen defined what are known as local parameter names. E.g. they are only referred to in the function implementation. • Sometimes its useful to name parameters when you call a function. These are called external parameter names.
  • 27. FUNCTIONS • shorthand for external parameter names:
  • 28. FUNCTIONTYPES • Variable that refer to functions can be defined:
  • 29. FUNCTIONTYPES • Functions can be passed as parameters:
  • 30. FUNCTIONTYPES • Functions can be returned from functions:
  • 31. NESTED FUNCTIONS • We can rewrite the previous examples with nested funcs: