-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Currently named parameters with default values often become useless as explicitly passing null stops the default occurring.
For example
foo({String blah: 'blah'});
bar({String blah}) => foo(blah: blah);
If blah is null into bar then it will pass that to foo and the default value not used
So in practice you end up needing to do
foo({String blah}) {
if (blah == null) blah = 'blah'
}
This seems to happen so often as to almost render defaults on named parameters fairly useless.
Does this proposal provide any help for this case?
Does it need extra sugar? Dare I suggest
foo(blah ?: possiblyNullValue);
where the semantics are if possiblyNullValue is null then don't set the named parameter blah to method foo (leave it to default)
Metadata
Metadata
Assignees
Labels
No labels