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

Implement something like "coalesce" (javascripts || or phps ?:) #6582

Closed
DartBot opened this issue Nov 7, 2012 · 3 comments
Closed

Implement something like "coalesce" (javascripts || or phps ?:) #6582

DartBot opened this issue Nov 7, 2012 · 3 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Nov 7, 2012

This issue was originally filed by emiliopl...@gmail.com


What steps will reproduce the problem?

I need to get the first not null argument in:

var shortName = coalesce(person.alias, person.name, person.completeName); // like PL

but I can't write it because there are not functions with infinite arguments.

or may be

var shortName = person.alias ?: person.name ?: person.completeName; // like php

But you must implement the operator ?: (or other with the same meaning)

or may be

var shortName = person.alias || person.name || person.completeName; // like JavaScript

But || it's only for booleans.

or may be

var shortName = [person.alias, person.name, person.completeName].firstNotNull();

But we can't extend List.

or may be

var shortName = coalesce([person.alias, person.name, person.completeName]);

but I don't like it. It's the only solution?

 

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

@madsager
Copy link
Contributor

madsager commented Nov 7, 2012

Removed Type-Defect label.
Added Type-Enhancement, Area-Language, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Nov 10, 2012

This comment was originally written by emiliopl...@gmail.com


I'm sorry. This is a duplicate issue. See dartbug.com/1236

@gbracha
Copy link
Contributor

gbracha commented Nov 10, 2012

Added Duplicate label.
Marked as being merged into #1236.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report labels Nov 10, 2012
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants