Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Robert Hand
PLUS
Robert Hand
Courses Plus 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!