nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1ef58d5
)
lib/standard: add Collection::not_empty
author
Jean Privat
<jean@pryen.org>
Mon, 30 Mar 2015 12:37:44 +0000
(19:37 +0700)
committer
Jean Privat
<jean@pryen.org>
Tue, 31 Mar 2015 00:37:46 +0000
(07:37 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>
lib/standard/collection/abstract_collection.nit
patch
|
blob
|
history
diff --git
a/lib/standard/collection/abstract_collection.nit
b/lib/standard/collection/abstract_collection.nit
index
d51e710
..
1b1e71e
100644
(file)
--- 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