Skip to content
Justice Tech School

Functions

func declares a function with typed parameters and a return type. Labels make calls read well.

Example
func add(_ a: Int, to b: Int) -> Int { a + b }
func greet(name: String) -> String { "Hello \(name)" }
print(add(2, to: 3))
print(greet(name: "Ada"))

Exercise

Return arrow.

func f()  Int

Quiz Test

What does _ do in a parameter?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.