As it says, there is no method for it. You could add it yourself: Base.getindex(f::Float64, ::Colon) = f # or whatever you like
However, the philosophical question is: should you be allowed to index into a float (or int)? Julia usually puts convenience before strictness and allows this. I'm not sure there are technical reasons to draw the line at `1[:]`. If no-one gives one, you could open a pull request (probably should add a method for `q[1:end]` too). On Mon, 2015-11-30 at 09:32, Ehsan Eftekhari <[email protected]> wrote: > I have a question about this behaviour of getindex in Julia: > > if I say > > julia> a=1.0 > 1.0 > > then > > julia> a[1] > 1.0 > > julia> a[end] > 1.0 > > but > > julia> a[:] > ERROR: MethodError: `getindex` has no method matching getindex(::Float64, > ::Colon) > Closest candidates are: > getindex(::Number) > getindex(::Number, ::Integer) > getindex(::Number, ::Integer...) > ... > > Why the last one does not work?
