I have a large cascading let - and midway through I'd like to make one assignment that's not an optional:
var b = [String: [ [String: Int]] ]()
if let a = b["foo"] where a.count > 0,
let c = a[0], // ** FAILS - not an optional assignment
let d = c["Howdie"] where d > 5
{
}
I'm finding more and more that I have this case. Now, I can just go use a[0] everywhere instead of the desired 'c', but the code is harder to read, and often in the body of the if I need 'c' too.
I know I could "hack" a way by making my code more complex - that is, instead of looking for an array of [String: Int], I could use [String: Any] instead,:
var b = [String: [ [String: Any]] ]()
if let a = b["foo"] where a.count > 0,
let c = a[0] as? [String: Int], // OK
let d = c["Howdie"] where d > 5
{
}
Is there something I'm missing? [Sigh, often is :-) ]