7
FUNCTIONS ARE A PARTY, AND YOU’RE INVITED
One of the most useful tools found in every programming language is the function. A function is a block of code that you can use again and again to perform a specific task. You can write your own custom functions, but Swift comes with lots of built-in functions. You’ve already used a few, like the print(_:) function, which displays a string in the console.
IN WITH THE INPUT, OUT WITH THE OUTPUT
Functions can take input and return output, although they don’t always have to. Input is information that you give to the function to perform its task, and output is something the function returns when it’s finished ...
Get Coding iPhone Apps for Kids, 1st Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.