Skip to content

Commit 95e21c5

Browse files
authored
Merge pull request #480 from JuliaLang/mh/lastindex
Add `lastindex`
2 parents 7d4dcd7 + 94f8f64 commit 95e21c5

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ Currently, the `@compat` macro supports the following syntaxes:
324324

325325
* `gc` and `gc_enable` are now `GC.gc` and `GC.enable`, respectively ([#25616]).
326326

327+
* `endof` is now `lastindex` ([#25458]). (Note that `lastindex(A, n)` is not supported.)
328+
327329
## New macros
328330

329331
* `@__DIR__` has been added ([#18380])
@@ -504,6 +506,7 @@ includes this fix. Find the minimum version from there.
504506
[#25241]: https://github.com/JuliaLang/julia/issues/25241
505507
[#25249]: https://github.com/JuliaLang/julia/issues/25249
506508
[#25402]: https://github.com/JuliaLang/julia/issues/25402
509+
[#25458]: https://github.com/JuliaLang/julia/issues/25458
507510
[#25459]: https://github.com/JuliaLang/julia/issues/25459
508511
[#25496]: https://github.com/JuliaLang/julia/issues/25496
509512
[#25544]: https://github.com/JuliaLang/julia/issues/25544

src/Compat.jl

+6
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,12 @@ else
14911491
import Distributed
14921492
end
14931493

1494+
# 0.7.0-DEV.3583
1495+
@static if !isdefined(Base, :lastindex)
1496+
const lastindex = endof
1497+
export lastindex
1498+
end
1499+
14941500
include("deprecated.jl")
14951501

14961502
end # module Compat

test/runtests.jl

+4
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,10 @@ end
12941294
@test !GC.enable(true)
12951295
@test GC.enable(true)
12961296

1297+
# 0.7.0-DEV.3583
1298+
@test lastindex(zeros(4)) == 4
1299+
@test lastindex(zeros(4,4)) == 16
1300+
12971301
if VERSION < v"0.6.0"
12981302
include("deprecated.jl")
12991303
end

0 commit comments

Comments
 (0)