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

Fix: Added missing section on comma rules #716

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,43 @@ const const message = "world"!
reverse!
```

## Comma grammar

To make code easier to maintain, DreamBerd supports tail commas.

```java
const const oneToThree = [
1,
2,
3, // <-- tail comma
]!
```

You can use commas instead of exclamation marks, or in combination with them to improve readibility.

```java
// These are all people
const var Thomas_Age = 10,
const var Jim_Age = 13!!,
const const Mom_Age = 25, // <-- tail comma
```

Combine commas with the `and` operator for more naturally written lists.

```java
const var bestDogs = ["Spot", "Fido", and "Clifford"]! // Oxford comma

var otherSchools = ["MIT", "Cambridge" and "Stanford"]! // If you didn't attend Oxford

// Phonetic instrumentation sample
const const boots = "kick + hi-hat";
const const cats = "snare + hi-hat";
funn MakeMusic(...) {
// ...
}
MakeMusic(boots and cats and boots and cats and)!!! // <-- tail `and`
```

## Class Names

For maximum compatibility with other languages, you can also use the `className` keyword when making classes.
Expand Down