On Tuesday, 18 June 2019 at 17:25:51 UTC, Johannes Loher wrote:
The result of heapify is a BinaryHeap, which is a range. writeln
basically prints ranges by iterating over them and printing
(except for the types which are special cased, such as dynamic
etc.). However, ranges are consumed by iterating over them,
explains the behavior because writeln is not special cased for
Funnily enough, BinaryHeap does not implement a "save" method,
which is the usual way of making ranges copiable, i.e. making
them ForwardRanges. In this case I believe save could even
simply be an alias to dup.
Do you known reason for why Dlang Range are consumed by iterating
over them. I this design is strange.