diff options
| author | Cliff Click <cliffc@acm.org> | 2026-10-02 13:04:34 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-10-02 13:04:34 -0700 |
| commit | e4dc3273f201ae741637b626998637cce973546b (patch) | |
| tree | 7607c1da4378da42549e8142371d95bdca4e06e0 /chapter17/README.md | |
| parent | 6cd01a8d646750748a0af221073de8a7787472ad (diff) | |
| download | Simple-e4dc3273f201ae741637b626998637cce973546b.tar.gz Simple-e4dc3273f201ae741637b626998637cce973546b.zip | |
First pass README updates
Diffstat (limited to 'chapter17/README.md')
| -rw-r--r-- | chapter17/README.md | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/chapter17/README.md b/chapter17/README.md index a3a2d992..ea1fef28 100644 --- a/chapter17/README.md +++ b/chapter17/README.md @@ -1,15 +1,19 @@ # Chapter 17: Syntax Sugar +[Previous: Chapter 16](../chapter16/README.md) | +[Next: Chapter 18](../chapter18/README.md) + + +## Table of Contents 1. [Pre/Post-increment](#prepost-increment) 2. [Operator assignment](#operator-assignment) 3. [var/val](#var--val) - - [Example(1)](#example1) - - [Example(2)](#example2) 4. [Mutability](#mutability) 5. [Reference immutability](#reference-variables-with-an-initializer-are-deeply-immutable) 6. [Trinary](#trinary) 7. [For Loops](#for-loops) +8. [Memory effects](#memory-effects) ## Pre/Post-increment @@ -38,7 +42,7 @@ Assignments associate right-to-left, as in `x |= y <<= 2`. ## var & val `var` can be used in the `type` position to indicate a "variable" (mutable -value), whose type will be inferred from the required initalizing expression. +value), whose type will be inferred from the required initializing expression. `val` is the same as `var`, except it is a "value" (not mutable). @@ -51,7 +55,7 @@ nullable, so e.g. infers as -`S s? = new S;` +`S? s = new S;` ## Mutability @@ -59,7 +63,7 @@ infers as Typed primitive fields are always mutable. Typed reference fields without an initializer must be mutable to get a value. Initialized reference variables are immutable by default and can be made mutable with a leading `!`. Contrast -this with what [chapter16](https://github.com/SeaOfNodes/Simple/tree/chapter16) +this with what [Chapter 16](../chapter16/README.md) did with `!`. `var` and `val` keep their current sense and can be used to make any field mutable or immutable. Fields are always mutable during construction, but will become immutable at the end of either constructor. |
