Thanks Mauro. As you predicted, my question was about the reasoning behind 
this behavior. If I remember correctly, it was not possible to use getindex 
on real numbers in Julia 0.3. I was not sure why it is added to 0.4.

On Monday, November 30, 2015 at 10:01:54 AM UTC+1, Mauro wrote:
>
> 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] 
> <javascript:>> 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? 
>

Reply via email to