Skip to content

Commit

Permalink
Merge pull request #1843 from stevengj/refscalar
Browse files Browse the repository at this point in the history
allow x[1] for scalar x
  • Loading branch information
JeffBezanson committed Dec 28, 2012
2 parents 9aed1f9 + 6215849 commit eb27af7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/number.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb27af7

Please sign in to comment.