Let's say I have a function like this:
func findFooById(id: String) -> Foo {
    if let foo = fooList[id] {
        return foo
    } else {
        assertionFailure("Couldn't find a foo with id = \(id)")
    }
}
In debug builds, I want my assertion to trigger so I'm clued into the fact my server is sending me inconsistent data. But in release builds, I want to return an empty foo (return Foo(id: "", name: "", magic: nil)) to keep my UI consistent.
(I'd prefer not to redefine findFooById to return Foo?, as that would force me to deal with nil in every caller. Displaying a blank object is good enough for this rare case.)
How do I achieve this?
 
     
    