dart-lang / dart-lang/language

Further extending the meaning of `?` to check for nulls

Open
#1,870 5 comments 9 reactions 0 assignees View on GitHub
feature
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

Currently, `?` can be used to mean "if not null". For example:

```
// If user is not null, do something
user?.doSomething(123);
```

Which is equivalent to:

```
// If user is not null, do something
if (user != null) user.doSomething(123);
```

I propose to extend this a little bit. Instead of:

```
// If user is not null, and name is not null, do something
if (user != null && name != null) doSomething();
```

I'd like to write:

```
// If user is not null, and name is not null, do something
if (user? && name?) doSomething();
```

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Start by reviewing the existing null-aware `?` behavior and the proposed examples; done means deciding and documenting the syntax and semantics of `if (user? && name?)`.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.