Iteration over OffsetArray

x = vec[begin]
y = vec[begin + 1]

it’s exactly how the begin/end syntax sugar works under the hood:

julia> Meta.@lower vec[begin + 1]
:($(Expr(:thunk, CodeInfo(
    @ none within `top-level scope`
1 ─ %1 = Base.firstindex(vec)
│   %2 = %1 + 1
│   %3 = Base.getindex(vec, %2)
└──      return %3
))))
3 Likes