Site-www: Document the new `Never` type

Created on 15 Jun 2020  路  8Comments  路  Source: dart-lang/site-www

As part of the wider null safety changes, Dart 2.9 has a new type, Never. This can be used as a return type:

  • void foo() {}: A function which usually returns normally, but doesn't return a (meaningful) result

  • Never foo() {}: A function which returns abnormally (e.g. throws or runs an infinite loop), e.g. the exit() function.

LanguageTour e1-hours new pagtopic request null-safety p1-high

Most helpful comment

We might want to at least mention this somewhere in the language tour, as well.

All 8 comments

https://dart.dev/guides/language/sound-dart would be a good place for this

We might want to at least mention this somewhere in the language tour, as well.

There's a bit of doc already: https://dart.dev/null-safety/understanding-null-safety. But we should mention it in /null-safety (and elsewhere, as null safety support progresses).

Hey @mit-mit, I read this issue and understood properly but to make things clear, exactly what is to be done is to update doc for the never keyword in comparison with void by explaining all things about never. If I'm not wrong may I work on this issue and update the doc for never, please guide me exactly which file is to be updated in doc. Thank you!

Hi @woinbo, I'll let @kwalrath (who oversees all our docs) answer those questions

@woinbo it's going to take some subtle work to make Never fit into the existing docs, so I'd like to do it myself but haven't found the time yet.

If you'd like to help, what I could really use is to figure out the exact places where Never should be discussed. (This sounds like what you asked mit to do, but the problem is that this kind of footwork takes time!)

Another way you could help might be with some simple yet illustrative example code.

@woinbo it's going to take some subtle work to make Never fit into the existing docs, so I'd like to do it myself but haven't found the time yet.

If you'd like to help, what I could really use is to figure out the exact places where Never should be discussed. (This sounds like what you asked mit to do, but the problem is that this kind of footwork takes time!)

Another way you could help might be with some simple yet illustrative example code.

@kwalrath example code, which describes the use of never in comparison of void, Right...?
Kathy, can you review these PR's too #2855 #2854 #2853

Was this page helpful?
0 / 5 - 0 ratings