Skip to content

Commit 1af92d6

Browse files
authored
Merge pull request #19 from JuliaMath/teh/promote
Support eltype promotion
2 parents 1c652f8 + 1deb38a commit 1af92d6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/closed.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,5 @@ function convert{R<:AbstractUnitRange,I<:Integer}(::Type{R}, i::ClosedInterval{I
8282
end
8383

8484
range{I<:Integer}(i::ClosedInterval{I}) = convert(UnitRange{I}, i)
85+
86+
Base.promote_rule{T1,T2}(::Type{ClosedInterval{T1}}, ::Type{ClosedInterval{T2}}) = ClosedInterval{promote_type(T1, T2)}

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ using Base.Test
8383

8484
@test width(ClosedInterval(3,7)) 4
8585
@test width(ClosedInterval(4.0,8.0)) 4.0
86+
87+
@test promote(1..2, 1.0..2.0) === (1.0..2.0, 1.0..2.0)
8688
end
8789
end
8890

0 commit comments

Comments
 (0)