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 trialAananya Vyas
20,157 Pointsit shows this in the preview what am i doing wrong??
swift_lint.swift:8:27: error: expected '{' to start getter definition var count : Int {get} ^ my code:
struct Queue<Element> {
var array: [Element] = []
var isEmpty: Bool {
if array.count == 0 {
return true
} else {
return false
}
}
}
struct Queue<Element> {
var array: [Element] = []
var count : Int {get}
var isEmpty: Bool {
if array.count == 0 {
return true
} else {
return false
}
}
}
1 Answer
miikis
44,957 PointsHi Aananya,
It looks like you copy-and-pasted a protocol declaration inside of your struct. Remove the {get} after your count declaration and you should be fine :)
Aananya Vyas
20,157 PointsAananya Vyas
20,157 Pointsit works in xcode.. not here..have tried it before .
miikis
44,957 Pointsmiikis
44,957 PointsThe Challenge is asking you to make count a computed-property... like you did for isEmpty. Let me know if that helps. Also, for isEmpty, you don't have to manually check the array's countโ you can just return array.isEmpty.