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
Daniel Grinspun
3,158 Pointshow can I use > < => with case statements?
import UIKit
let listadoDePuntajes = [30, 40, 100, 800,7] var totalPuntajes = 0
for i in listadoDePuntajes {
switch i {
case > 50:
totalPuntajes += 1
default:
totalPuntajes += 0
}
}
print(totalPuntajes)
it doesn't work
2 Answers
Bill Merickel
11,420 PointsDo an if statement instead of switch. if I > 50 { }
Pasan Premaratne
Treehouse TeacherIt's not possible directly like you're using it but you can add an additional condition using a where clause, Examples here