From 62158498a110507b9ba544f12b1523681d07596d Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Fri, 28 Dec 2012 17:05:03 -0500 Subject: [PATCH] allow x[1] for scalar x, to be consistent with the treatment of 0-dimensional arrays [since ndims(x)==0 and length(x)==numel(x)==1] --- base/number.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/number.jl b/base/number.jl index ed7a31d8b1bf7..220b4c101a24c 100644 --- a/base/number.jl +++ b/base/number.jl @@ -20,6 +20,8 @@ ndims(x::Number) = 0 ndims{T<:Number}(::Type{T}) = 0 length(x::Number) = 1 ref(x::Number) = x +ref(x::Number, i::Integer) = i == 1 ? x : throw(BoundsError()) +ref(x::Number, i::Real) = ref(x, to_index(i)) signbit(x::Real) = int(x < 0) sign(x::Real) = x < 0 ? -one(x) : x > 0 ? one(x) : x