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

Xcode 8 Console not Displaying Result

Hey guys and girls, I am a beginning Swift programmer and I am making an area calculator in Xcode to practice my use of functions. However, when I finished writing my code I noticed that the console in Xcode would not print out anything. Is there anything wrong with my code or is it just that the Xcode console is kind of not working and needs to be fixed in the next update?

Here is my code:

func areaCalculator(length: Int, width: Int) -> Int { let area = length * width return area }

areaCalculator(length: 8, width: 8)

What I meant for the code to do is to return 64 to the console, since I entered 8 for length and also 8 for width. However, the console is not responding and is showing nothing.

1 Answer

Thomas Dobson
Thomas Dobson
7,511 Points

Han,

func areaCalculator(length: Int, width: Int) -> Int
{
  let area = length * width
  return area
}

areaCalculator(length: 8, width: 8)

This code works fine. Xcode playgrounds are a constant frustration for me. Often code stops/gets stuck compiling in real time. The best solution I have found to temporarily remediate the problem is to fully quit xcode, and relaunch xcode and my playground.

I hope this helps!

Thanks!