|
@@ -60,20 +60,14 @@ to write the data instead.
|
|
|
- if _subarray_ path element `#(bar)` is read from _foo_, `foo bar` is performed;
|
|
|
- if _subarray_ path element `#(bar)` is written to _foo_, `foo bar: value` is performed.
|
|
|
|
|
|
-###API
|
|
|
+For example reading `container` at axes `#((todos) 1 done)` essentially does
|
|
|
|
|
|
-----
|
|
|
-
|
|
|
-```st
|
|
|
-Object >> atAxes: aCollection ifAbsent: aBlock
|
|
|
+```smalltalk
|
|
|
+| x |
|
|
|
+x := container todos at: 1.
|
|
|
+^ x at: 'done'
|
|
|
```
|
|
|
|
|
|
-For example `container atAxes: #((todos) 1 done) ifAbsent: [...]'` essentially does
|
|
|
-
|
|
|
- | x |
|
|
|
- x := container todos at: 1.
|
|
|
- ^ x at: 'done'
|
|
|
-
|
|
|
But, whenever:
|
|
|
|
|
|
- `container` fails to perform `todos`, or
|
|
@@ -82,20 +76,17 @@ But, whenever:
|
|
|
- `container todos at: 1` fails to perform `at:ifAbsent:`, or
|
|
|
- `container todos at: 1` does not contain index 'done',
|
|
|
|
|
|
-the `ifAbsent` block value is returned.
|
|
|
+the "failed to get" fallback is taken.
|
|
|
|
|
|
-----
|
|
|
+Similarly, putting `true` into `container` at axes: `#((todos) 1 done)`
|
|
|
+essentially does
|
|
|
|
|
|
-```st
|
|
|
-Object >> atAxes: aCollection ifAbsent: aBlock put: anObject
|
|
|
+```smalltalk
|
|
|
+| x |
|
|
|
+x := container todos at: 1.
|
|
|
+^ x at: 'done' put: true
|
|
|
```
|
|
|
|
|
|
-For example `container atAxes: #((todos) 1 done) ifAbsent: [...] put: 'foo'` essentially does
|
|
|
-
|
|
|
- | x |
|
|
|
- x := container todos at: 1.
|
|
|
- ^ x at: 'done' put: 'foo'
|
|
|
-
|
|
|
But, whenever:
|
|
|
|
|
|
- `container` fails to perform `todos`, or
|
|
@@ -103,19 +94,12 @@ But, whenever:
|
|
|
- `container todos` does not contain index 1, or
|
|
|
- `container todos at: 1` fails to do `at:put:`,
|
|
|
|
|
|
-the `ifAbsent` block value is returned.
|
|
|
-
|
|
|
-----
|
|
|
-
|
|
|
-```st
|
|
|
-Axes class >> parse: aString
|
|
|
-```
|
|
|
-
|
|
|
-Parses a string to get a proper array index to use with `atAxes:` API.
|
|
|
+the "failed to put" fallback is taken.
|
|
|
|
|
|
-The syntax is resembling Smalltalk literal array syntax very closely.
|
|
|
-For example `Axes parse: '(value)'` and `Axes parse: '(todos) 1 done'`
|
|
|
-produce `#((value))` and `#((todos) 1 done)` as results.
|
|
|
+`Axes` class can parse a string representation of axes. The syntax
|
|
|
+of the string representation is resembling Smalltalk literal array syntax
|
|
|
+very closely. For example `Axes parse: '(value)'` and `Axes parse:
|
|
|
+'(todos) 1 done'` produce `#((value))` and `#((todos) 1 done)` as results.
|
|
|
|
|
|
Syntactic sugar: as `(foo)` happens often, to denote unary selector,
|
|
|
it can be written equivalently as `~foo`, to improve readability.
|