The difference is that slice reduces all sizes sliced βββslicedβ using scalar (not vector), and sub often saves them. For example:
julia> A = rand(3,3) 3x3 Array{Float64,2}: 0.403464 0.229403 0.924686 0.953741 0.175086 0.49139 0.0290678 0.705564 0.567355 julia> a = slice(A, 2, :)
There is one exception: sub reduces the dimensions indexed with the scalar if they are βfinalβ dimensions, which means that later sizes are not indexed with the vector:
julia> a = slice(A, :, 2) 3-element SubArray{Float64,1,Array{Float64,2},(Colon,Int64),2}: 0.229403 0.175086 0.705564 julia> b = sub(A, :, 2) 3-element SubArray{Float64,1,Array{Float64,2},(Colon,Int64),2}: 0.229403 0.175086 0.705564 julia> size(a) (3,) julia> size(b) (3,)
If you are slice with a range, you will get behavior similar to sub :
julia> a = slice(A, 2:2, :) 1x3 SubArray{Float64,2,Array{Float64,2},(UnitRange{Int64},Colon),1}: 0.953741 0.175086 0.49139 julia> size(a) (1,3)
It does not matter the length of the index, it is a type: any dimension indexed with Nescal will be saved.