lib/collections: intro `Map::not_empty`
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 28 Jul 2015 16:09:45 +0000 (12:09 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 29 Jul 2015 12:26:30 +0000 (08:26 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/standard/collection/abstract_collection.nit

index 39938bd..5192797 100644 (file)
@@ -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]