Home > Back-end >  Why don't use semicolon at end of class in dart language?
Why don't use semicolon at end of class in dart language?

Time:02-21

Dart programming language. My question is Why don't use semicolons at end of class in dart language? I tried to find the answer to this question but the answer I have gained is that the answer does not have a proper meaning of my question. The answer is

"Don't put semicolons at the end of compound statements Compound statements have code blocks whose scope is defined by curly braces. You don't use semicolons after the closing curly brace"

CodePudding user response:

The answer is: the language designers chose this to be the case. And this is not just the case for Dart. Swift, Rust, Python and many other languages do not accept a semicolon to end a class definition.

You can read the official Dart language specifications here: https://dart.dev/guides/language/specifications/DartLangSpec-v2.10.pdf

CodePudding user response:

The simple answer is: because that is the definition. It's man made. It was a decision by the language creators. There is no other external reason to be found.

Why they made that decision is probably not extensively documented. It wasn't needed. There is no need for a semicolon, so none was used.

  • Related