Add LValue.truth() to return whether a value is (not(false) and not(nil))

Fri, 19 Nov 2010 19:41:57 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 19 Nov 2010 19:41:57 +0000
changeset 86
97678a1565d4
parent 85
25470393fe74
child 87
07d19518e89a

Add LValue.truth() to return whether a value is (not(false) and not(nil))

lvm.js file | annotate | diff | comparison | revisions
--- a/lvm.js	Fri Nov 19 19:28:48 2010 +0000
+++ b/lvm.js	Fri Nov 19 19:41:57 2010 +0000
@@ -99,6 +99,12 @@
 			return this.value.toString();
 		}
 	},
+	truth: function ()
+	{
+		if(this.type == "nil" || (this.type == "boolean" && this.value == false))
+			return false;
+		return true;
+	},
 	add: function (op2)
 	{
 		var metamethod;

mercurial