For sol::ODESolution from DifferentialEquations.jl, it can be called as
sol[1:2, 2:3]
in addition to having properties to call and utilize.
How does one design a struct whose instances behave as such?
For sol::ODESolution from DifferentialEquations.jl, it can be called as
sol[1:2, 2:3]
in addition to having properties to call and utilize.
How does one design a struct whose instances behave as such?
To support indexing, a struct needs to implement an appropriate getindex method: sol[1:2, 2:3] is equivalent to getindex(sol, 1:2, 2:3). An example is given here in the documentation.
The ODESolution type implements more than just Base.getindex. Since it is an actual AbstractArray subtype, it also has a size etc. The methods required for an AbstractArray are also listed on the documentation page linked above.