From eb6cbbff84432171e9f1f45f3d9577f92cf504d2 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Mon, 30 Mar 2015 19:37:44 +0700 Subject: [PATCH] lib/standard: add Collection::not_empty Signed-off-by: Jean Privat --- lib/standard/collection/abstract_collection.nit | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/standard/collection/abstract_collection.nit b/lib/standard/collection/abstract_collection.nit index d51e710..1b1e71e 100644 --- a/lib/standard/collection/abstract_collection.nit +++ b/lib/standard/collection/abstract_collection.nit @@ -66,6 +66,14 @@ interface Collection[E] # assert [1..1[.is_empty == true fun is_empty: Bool do return length == 0 + # Alias for `not is_empty`. + # + # Some people prefer to have conditions grammatically easier to read. + # + # assert [1,2,3].not_empty == true + # assert [1..1[.not_empty == false + fun not_empty: Bool do return not self.is_empty + # Number of items in the collection. # # assert [10,20,30].length == 3 -- 1.7.9.5