diff options
| author | Cliff Click <cliffc@acm.org> | 2024-11-14 09:19:17 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2024-11-23 09:03:20 -0800 |
| commit | 20e598812cfe3bf2241e4c856e017acb29f13192 (patch) | |
| tree | 8ed27e24b02a76f856e9ca7ff84724f34eb6dcf0 /chapter17 | |
| parent | 8152aa68809d8af709b01017a27ade1ca5480ddf (diff) | |
| download | Simple-20e598812cfe3bf2241e4c856e017acb29f13192.tar.gz Simple-20e598812cfe3bf2241e4c856e017acb29f13192.zip | |
more readme
Diffstat (limited to 'chapter17')
| -rw-r--r-- | chapter17/README.md | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/chapter17/README.md b/chapter17/README.md index d65ff879..e37fa9b7 100644 --- a/chapter17/README.md +++ b/chapter17/README.md @@ -78,7 +78,6 @@ the same reference can exist. This works for `var` and normal type declarations: `var s = new S;` and `S s = new S` both make `s` an immutable reference to a `struct S`. - ```cpp struct Bar { int x; } Bar !bar = new Bar; @@ -97,9 +96,6 @@ foo.bar.x++; // Bumps to 5 print(xfoo.bar.x); // Ok to read through xfoo, prints 5 ``` - - - ## Trinary Allow `pred ? e_true : e_false`. Also allow `pred ? e_true`, where the false result @@ -117,17 +113,17 @@ Example: ```cpp int sum=0; for( int i=0; i<arg; i++ ) - sum = sum + i; + sum += i; return sum; ``` -Any of `init`, `test` and `next` can be empty. -`init` allows for declaration of a new variable, with scope limited to the `for` expression. +Any of `init`, `test` and `next` can be empty. `init` allows for declaration +of a new variable, with scope limited to the `for` expression. ```cpp int sum=0; for( int i=0; i<arg; i++ ) - sum = sum + i; + sum += i; return i; // ERROR: Undefined name 'i' ``` |
