From ea4117572594d87bddc8c60763935fa92cff7e3d Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Wed, 11 Jan 2017 07:23:16 +0000 Subject: [PATCH] Added isNil*(Value). --- src/private/value.nim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/private/value.nim b/src/private/value.nim index 7f10ee2..2f3e647 100644 --- a/src/private/value.nim +++ b/src/private/value.nim @@ -102,6 +102,17 @@ proc `==`*(a, b: Value): bool = a.kind == b.kind and a.str == b.str +proc isNil*(v: Value): bool = + case v.kind + of vkNone: + result = true + of vkStr: + result = v.str_v.isNil + of vkList: + result = v.list_v.isNil + else: + result = false + proc val(): Value = Value(kind: vkNone) proc val(v: bool): Value = Value(kind: vkBool, bool_v: v) proc val(v: int): Value = Value(kind: vkInt, int_v: v)