Question

I know that in julia creating binary operator overloads is easy, e.g.

+(x,y) = x*y

I also know that a[i] is an abbreviation to getindex and setindex!

I would like to know how to overload subarray operators, such as

a[i,j,:,3:]

I believe this is just a function called but am unable to find its name

Was it helpful?

Solution

@which macro helps finding right method to overload:

julia> sample=rand(3,4,5);

julia> @which(sample[1,1,1])
getindex(A::Array{T,N}, i1::Real, i2::Real, I::Real...) at array.jl:283

julia> @which(sample[1,1,:])
getindex(A::AbstractArray{T,N}, I...) at abstractarray.jl:487
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top