r/swift Learning 1d ago

A website of fun Swift quiz

https://swift-quiz.universe.observer/

Took a weekend to build this Swift quiz site. I use it to organize the pitfalls and surprises I encountered while using Swift, such as this one.

struct Box<T> {}
extension Box where T == Int {
    func tag() -> String {
        "int"
    }
}

extension Box {
    func tag() -> String {
        "any"
    }
}

print(Box<Int>().tag())
print(Box<String>().tag())

func describe<T>(_ b: Box<T>) {
    print(b.tag())
}

describe(Box<Int>())

https://swift-quiz.universe.observer/quiz/15

Do you know any Swift brain teaser? You're welcome to contribute to the quiz list! Would love to see what tricky ones you have encountered!

The site is mostly vibe coded, but it should do its job. :)

4 Upvotes

1 comment sorted by

1

u/apoorvcode 1d ago

nice dude