On Sat, Jul 30, 2016 at 7:30 PM, Chris Rackauckas <[email protected]> wrote:
> I thought arr[end] just called endof(arr), but that seems to not be the
> case. For example:
>
julia> expand(:(a[end]))
:(getindex(a,(Base.endof)(a)))
> type TestType
> data::AbstractArray
> end
> Base.length(t::TestType) = length(t.data)
> Base.size(t::TestType) = (length(t.data))
> Base.endof(t::TestType) = t.data[2,:,:]
> Base.getindex(t::TestType,i::Int) = t.data[i,:,:]
>
> t = TestType(rand(4,4,3))
> t[1]; t[2]; t[3]; t[4] #These all work
> t.data[end,:,:] == t.data[4,:,:] #This works
> endof(t) #This works
> t[end] #No method matchin getindex(::TestType,::Array{Float64,2})
>
> So if endof(t) != t[end], how exactly can one define it? Why is it calling
> getindex(::TestType,::Array{Float64,2})?