Repository navigation
Generate No Arg constructor that uses defaults #186
Bradleycorn
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
SKIE already has a Default Args Interop feature that can be enabled to allow for default args in Swift.
However, it can be problematic to use, particularly as the number of default args on a function grows larger and the number of generated overloads grows exponentially.
I am proposing a feature/option that's sort of a middle ground, and just produces a single extra overload that uses ALL of the defaults.
For example, take the following function that has 1 required argument, and 3 optional arguments:
With this middle ground flag enabled, swift code could call one of two overloads of this method:
Just an idea ... I find myself writing a lot of these myself for methods/data classes that produce application/UI State. They may take many arguments (more than 5), but have sane defaults for most/all of them (suitable for use when the app/UI first loads, or in previews, tests, etc). I'll write an overload that takes no args (or only args that are required) and calls the original, letting it use it's defaults for all of the args that have them. It would be nice if I didn't have to write these myself.
All reactions