From: Jean Privat Date: Fri, 15 Aug 2014 19:56:27 +0000 (-0400) Subject: lib: add Seq:prepend as an alias of `insert_all(0)` X-Git-Tag: v0.6.8~16^2~1 X-Git-Url: http://nitlanguage.org?ds=sidebyside lib: add Seq:prepend as an alias of `insert_all(0)` Signed-off-by: Jean Privat --- diff --git a/lib/standard/collection/abstract_collection.nit b/lib/standard/collection/abstract_collection.nit index b99c465..a806c57 100644 --- a/lib/standard/collection/abstract_collection.nit +++ b/lib/standard/collection/abstract_collection.nit @@ -803,6 +803,15 @@ interface Sequence[E] # assert a == [20,10,1,2,3] fun unshift(e: E) is abstract + # Add all items of `coll` before the first one. + # + # var a = [1,2,3] + # a.prepend([7..9]) + # assert a == [7,8,9,1,2,3] + # + # Alias of `insert_at(coll, 0)` + fun prepend(coll: Collection[E]) do insert_all(coll, 0) + # Remove the first item. # The second item thus become the first. #