lib/math: nitunit `Collection::rand`
authorJean Privat <jean@pryen.org>
Tue, 5 May 2015 18:23:57 +0000 (14:23 -0400)
committerJean Privat <jean@pryen.org>
Tue, 5 May 2015 18:23:57 +0000 (14:23 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

lib/standard/math.nit

index 2b55dca..b6f7153 100644 (file)
@@ -241,6 +241,11 @@ end
 redef class Collection[ E ]
        # Return a random element form the collection
        # There must be at least one element in the collection
+       #
+       # ~~~
+       # var x = [1,2,3].rand
+       # assert x == 1 or x == 2 or x == 3
+       # ~~~
        fun rand: E
        do
                if is_empty then abort