Commit 91505bb
authored
Currently, it is possible to index into a `CartesianIndex` using an
`Int` index.
```julia
julia> I = CartesianIndex(4,3)
CartesianIndex(4, 3)
julia> I[1]
4
julia> I[2]
3
```
This PR adds the ability to use `begin`/`end` in the indexing:
```julia
julia> I[begin]
4
julia> I[end]
3
```
The advantage of this (particularly indexing with `end`) is that one
doesn't need to know the number of dimensions. This makes writing
generic code that accepts either a vector or a matrix easier.
1 parent c5d97f8 commit 91505bb
2 files changed
+9
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
106 | 108 | | |
107 | 109 | | |
108 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
582 | 582 | | |
583 | 583 | | |
584 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
0 commit comments