Skip to content

Commit 5fefef8

Browse files
committed
Support copying range objects
This commit adds a deep-copy operation for range objects. If this is not desired, feel free to ignore.
1 parent 327c39c commit 5fefef8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

jl/range.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ last{T}(r::Range1{T}) = r.start + oftype(T,r.len-1)
6767
step(r::Range) = r.step
6868
step(r::Range1) = one(r.start)
6969

70+
copy(r::Range) = Range(copy(r.start),
71+
copy(r.step),
72+
copy(r.len))
73+
copy(r::Range1) = Range1(copy(r.start),
74+
copy(r.len))
75+
7076
function ref{T}(r::Range{T}, i::Integer)
7177
if !(1 <= i <= r.len); error(BoundsError); end
7278
r.start + oftype(T,i-1)*step(r)

0 commit comments

Comments
 (0)