Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Generics in Swift Generic Types Creating a Generic Type

Need help here!

Hello all, been stuck on this one for a day now. Im pretty sure that the problem lies in the way I'm declaring the computed property self.isEmpty. Specifically the return statement. I just don't know how to fix it. I have looked up some references but can fully find the solution. Any help would be appreciated. Thanks!

struct Queue<Element> {
    var array: [Element]
    var isEmpty: Bool

    init(Element: [Element]) {
        self.array = Element
        self.isEmpty = Bool {
          return .isEmpty }


1 Answer

Jeff McDivitt
Jeff McDivitt
23,970 Points

You are on the right track, but you do not need to initialize anything in this challenge. You can replace that with isBool. Then you can check if the array is empty and return true else return false

struct Queue<Element> {

    var array: [Element] = []

    var isEmpty: Bool {
        if array.count == 0 {
            return true
        } else {
            return false


Thanks so much Jeff! I got confused with the language they used in the first task "initialize it to an empty array" Your answer clarified that for me. Thank You!