From 422e8699ece14a974bde2a9b73f84e67bf82ce51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Tue, 28 Jul 2015 12:09:45 -0400 Subject: [PATCH] lib/collections: intro `Map::not_empty` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/standard/collection/abstract_collection.nit | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/standard/collection/abstract_collection.nit b/lib/standard/collection/abstract_collection.nit index 39938bd..5192797 100644 --- a/lib/standard/collection/abstract_collection.nit +++ b/lib/standard/collection/abstract_collection.nit @@ -534,6 +534,16 @@ interface MapRead[K, V] # assert x.is_empty == false fun is_empty: Bool is abstract + # Alias for `not is_empty`. + # + # Some people prefer to have conditions grammatically easier to read. + # + # var map = new HashMap[String, Int] + # assert map.not_empty == false + # map["one"] = 1 + # assert map.not_empty == true + fun not_empty: Bool do return not self.is_empty + # Number of items in the collection. # # var x = new HashMap[String, Int] -- 1.7.9.5