From: Alexandre Terrasa Date: Thu, 12 Oct 2017 00:47:50 +0000 (-0400) Subject: lib/vsm: access to non-existing keys return 0.0 X-Git-Url: http://nitlanguage.org lib/vsm: access to non-existing keys return 0.0 Signed-off-by: Alexandre Terrasa --- diff --git a/lib/vsm/vsm.nit b/lib/vsm/vsm.nit index 41d5152..8eaeca8 100644 --- a/lib/vsm/vsm.nit +++ b/lib/vsm/vsm.nit @@ -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`