Skip to content

Commit 21de975

Browse files
committed
collection/list: Add contracts usage
Signed-off-by: Florian Deljarry <deljarry.florian@gmail.com>
1 parent 7c61c23 commit 21de975

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lib/core/collection/list.nit

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ class List[E]
7070
end
7171

7272
# Return a list of elements between 'from' and 'to'.
73-
fun slice(from: Int, to: Int): List[E] do
74-
assert from >= 0 and from < length
75-
assert to >= 0 and to < length and from <= to
73+
#
74+
# EXPECTS(from >= 0 and from < length and to >= 0 and to < length and from <= to)
75+
fun slice(from: Int, to: Int): List[E]
76+
is
77+
expects(from >= 0 and from < length and to >= 0 and to < length and from <= to)
78+
do
7679
var list = new List[E]
7780
while from <= to do
7881
list.add(self[from])

0 commit comments

Comments
 (0)