Skip to content

Commit 49611ce

Browse files
author
Pietro Vertechi
authored
fix backticks (#202)
1 parent 8958925 commit 49611ce

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/src/counterintuitive.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ julia> x # remains unchanged
2424
```
2525
The assignment `x[1].a = 10` first calls `getindex(x,1)`, then sets property `a` of the accessed element. However, since StructArrays constructs `Foo(x.a[1],x.b[1])` on the fly when when accessing `x[1]`, setting `x[1].a = 10` modifies the materialized struct rather than the StructArray `x`.
2626

27-
Note that one can modify a field of a StructArray entry via `x.a[1] = 10` (the order of `getproperty` and `getindex` matters). As an added benefit, this does not require that the struct `Foo` is mutable, as it modifies the underlying component array `x.a` directly.
27+
Note that one can modify a field of a StructArray entry via `x.a[1] = 10` (the order of `.` syntax and indexing syntax matters). As an added benefit, this does not require that the struct `Foo` is mutable, as it modifies the underlying component array `x.a` directly.
2828

2929
For mutable structs, it is possible to write code that works for both regular `Array`s and `StructArray`s with the following trick:
3030
```julia
31-
x[1] = x[1].a = 10
32-
```
31+
x[1] = x[1].a = 10
32+
```
3333

3434
`x[1].a = 10` creates a new `Foo` element, modifies the field `a`, then returns the modified struct. Assigning this to `x[1]` then unpacks `a` and `b` from the modified struct and assigns entries of the component arrays `x.a[1] = a`, `x.b[1] = b`.
3535

0 commit comments

Comments
 (0)