lib/vsm: access to non-existing keys return 0.0
[nit.git] / lib / vsm / vsm.nit
index 41d5152..8eaeca8 100644 (file)
@@ -72,6 +72,11 @@ class Vector
                return cos
        end
 
+       redef fun [](k) do
+               if not has_key(k) then return 0.0
+               return super
+       end
+
        # The norm of the vector.
        #
        # `||x|| = (x1 ** 2 ... + xn ** 2).sqrt`