Add nil-collapsing call expression

I was going to say the same thing, but requires that all arguments are some, while the proposal allows some to go through as nil. So this is fine if you zip only the "uncertain" arguments, but not if you zip them all

You just wouldn’t pass the ones you don’t want to be guaranteed to be .some to the zip (you also don’t need to pass things that are not optional to begin with).

zip(optionalA, optionalB) { foo($0, $1, otherThing) }

I agree that this is only syntax sugar, but for something that is used so often, the work arounds are

Especially when there is more than 1 optional argument.

That’s just bikeshedding, but I am worried about using « ¿ », I have never seen it in any programming language and, except for Spanish speakers I don’t think people are generally used to how to type it on their keyboard.

Other than that I would really appreciate this feature to be implemented, it isn’t something I need on an everyday basis, but I have already had several cases where I really felt like my code would have been much cleaner if it existed.
Ability to collapse per parameter is probably nice to have too.

I think people are generally unable to type it on their keyboard at all. For example it doesn't exist on my keymap (polish pro on mac)

Daniel_Resnick syntax is much better. Just add a ? to the end of the optional. This is the exact same syntax as forced unwrap. no ¿ is required.

Do you mean you can’t type it even with modification keys?

Yes. I cannot find it on Mac, on Ubuntu with Polish keyboard layout it's right alt+shift+2 and it seems that the only character not printed on a keyboard that I can type in Polish(Programmers) layout on Windows is €

That surprised me too and at first I just thought he did not know how. But I switched to the Polish programming keyboard and @cukr is right.

Though in general, there are ways of fixing that sort of problem...

1 Like
Terms of Service

Privacy Policy

Cookie Policy