I like to use guardit because it makes your intentions understandable. I used it as an additional version, for example ...
guard let c = MyOptionalArray else { return }
as well as for checking more traditional restrictions on non-options ...
guard MyArray.count > 0 else { return }
But now I would like to use this countin the following code. So what I did ...
guard let c = MyArray.count > 0 else { return }
which doesn't work, obviously, so I did what should ...
guard let c = parts.count where c > 1 else { return }
But that says Initializer for conditional binding must have Optional type, not 'Int'. Now I understand the error and tried a bunch of seemingly obvious changes in the format, but did not go. Is it not possible to use protection as a destination for an optional value? It is like what he has to do.
source
share