You want to store the array object inside Cubes.
type Cubes{T,N} <: AbstractArray{T,N}
data::Array{T,N}
end
sum(cubes::Cubes) = sum(cubes.data.^3)
--Tim
On Saturday, April 25, 2015 04:50:52 AM Marcus Appelros wrote:
> Consider the definitions:
>
> type Cubes<:AbstractArray
> end
> sum(cubes::Cubes)=sum(convert(Array,cubes).^3)
>
> Is it possible to make this work? To create a custom array that has
> indexing and all at inception? Looked up the definition of Array and it is
> in the commented section on types implemented in C, its constructor is a
> ccall, if it isn't possible in pure julia would it be possible with C-code
> that doesn't prompt a rebuild?