Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Swift iOS Programming for Kids

You're reading from   Swift iOS Programming for Kids Help your kids build simple and engaging applications with Swift 3.0

Arrow left icon
Product type Paperback
Published in Mar 2017
Publisher Packt
ISBN-13 9781787120747
Length 260 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Steffen D. Sommer Steffen D. Sommer
Author Profile Icon Steffen D. Sommer
Steffen D. Sommer
Jim Campagno Jim Campagno
Author Profile Icon Jim Campagno
Jim Campagno
Arrow right icon
View More author details
Toc

What is a function?


Going back to Chapter 1What is Programming?, you may remember that we defined programming as writing a set of instructions for a computer to execute. A function is a block of reusable code or instructions which generally performs a single specific task. A function abstracts one or more instructions and gives us a reference to that block of instructions. Chapter 4Favorite Things, showed us how to reference values using variables. In this chapter, you will learn that a function is basically a set of instructions or a chunk of code that is grouped together and referenced by a function name.

Let's imagine a real-world example for a moment. When you want to order a pizza, you call your local pizza joint. The people working at the pizza joint will then note down your order, put it into their queue of orders, make the pizza specified in your order and lastly, have it delivered to your address.

Actually, we can model these tasks as multiple functions:

  • A function to receive the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime