iOS Closures in Swift First Class Functions Functions as First Class Citizens

Robert Hand
PRO
Robert Hand
Pro Student 2,657 Points

Closures in Swift 3 - Need Help

Challenge Task 1 of 2

Write a function named addTwo that accepts an Int, adds the value 2 to it and returns the resulting integer. Name the external argument label to. Note: This task doesn't require that you call the function yet.

This is my code:

func addTwo(to: Int + 2) -> Int

Not sure what to do from here...

functions.swift
// Enter your code below

func addTwo(Int + 2) -> Int 

1 Answer

Robert,

Here is the code that I used that passed challenges one & two:

func addTwo(to: Int) -> Int {
    return to + 2
}

let addition = addTwo
let result = addition(6)

From part one of the challenge, it appears that you did not add the curly brackets and return functionality.

If you have any questions, feel free to ask!