MultiHashMap: Add a test for `add_one`
authorJean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Wed, 10 Aug 2016 15:43:48 +0000 (11:43 -0400)
committerJean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Tue, 16 May 2017 02:44:05 +0000 (22:44 -0400)
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

lib/more_collections.nit

index 3062d5e..2ea732a 100644 (file)
@@ -35,7 +35,18 @@ class MultiHashMap[K, V]
        super HashMap[K, Array[V]]
 
        # Add `v` to the array associated with `k`.
+       #
        # If there is no array associated, then create it.
+       #
+       # ```
+       # var m = new MultiHashMap[String, Char]
+       # m.add_one("four", 'i')
+       # m.add_one("four", 'i')
+       # m.add_one("four", 'i')
+       # m.add_one("four", 'i')
+       # assert m.has_key("four")
+       # assert m["four"] == ['i', 'i', 'i', 'i']
+       # ```
        fun add_one(k: K, v: V)
        do
                var x = self.get_or_null(k)