Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application to named parameters #12

Open
Andersmholmgren opened this issue May 26, 2015 · 1 comment
Open

Application to named parameters #12

Andersmholmgren opened this issue May 26, 2015 · 1 comment

Comments

@Andersmholmgren
Copy link

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)

@zoechi
Copy link

zoechi commented May 26, 2015

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants