Challenge: Flattening nested optionals

When you slice a slice of a collection, sometimes, you get Slice<Slice<Collection>> instead of Slice<Collection>. WWDC18 session 229 (starting from 11:04 mark) talked about it in more detail.

You wouldn't get nested Slice under essentially any slice operations. Collection specifically requires SubSequence to be its own SubSequence. And generic Slice is already its own SubSequence.

I could come up accidentally if you use Slice<X> instead of X.SubSequence, but that's rather contrived.

1 Like

That's what I need.
Solved a long-standing problem in my code

Before that
I use:

String(describing: _data) == "Optional(nil)"

po _data
▿ Optional
- some : nil

1 Like