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 Swift Functions and Optionals Optionals Exercise: isDivisible function

Question - Amit says we can 'get a drink' before attempting to write our code. Can we have beer?

Problem, it's still morning.

6 Answers

Ha ha XD I was in one course with another instructor and he said we should take a drink too, to relax hahaha I think he said tea or coffee though. So, you don't need to have a "drink" like beer, water is a drink too. Drink water, it will be a good thing to do early in the morning.

John Adapon
John Adapon
15,769 Points

There is no rule on when not to drink beer and Walmart is open ;)

Rafael Schwemmer
Rafael Schwemmer
6,109 Points

I think "Drink" is an Optional here:

var drink: String? = "Beer"

We can then use a range and a for-in loop to consume a six pack by unwrapping each beer can in the loop with a !:

for number in 1...6 {
  println("Drinking \(drink!) number \(number)")


  • Drinking Beer number 1
  • Drinking Beer number 2
  • Drinking Beer number 3
  • Drinking Beer number 4
  • Drinking Beer number 5
  • Drinking Beer number 6

Warning: Optional Chaining with Vodka is not recommended, it will result in CRASH! ;-)


"The best time to have a beer (or two) would be when you’re searching for an initial idea. Because alcohol helps decrease your working memory (making you feel relaxed and less worried about what’s going on around you), you’ll have more brain power dedicated to making deeper connections."


have a beer;)