The Squirrel interpreter. See http://www.squirrel-lang.org/

Dependents:   Squirrel

Revision:
0:97a4f8cc534c
diff -r 000000000000 -r 97a4f8cc534c samples/class.nut
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/class.nut	Tue Dec 16 10:20:34 2014 +0000
@@ -0,0 +1,49 @@
+//////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////
+class BaseVector {
+	constructor(...)
+	{
+		if(vargv.len() >= 3) {
+			x = vargv[0];
+			y = vargv[1];
+			z = vargv[2];
+		}
+	}
+	
+	
+	x = 0;
+	y = 0;
+	z = 0;
+}
+
+class Vector3 extends BaseVector {
+	function _add(other)
+	{
+		if(other instanceof this.getclass())
+			return ::Vector3(x+other.x,y+other.y,z+other.z);
+		else
+			throw "wrong parameter";
+	}
+	function Print()
+	{
+		::print(x+","+y+","+z+"\n");
+	}
+}
+
+local v0 = Vector3(1,2,3)
+local v1 = Vector3(11,12,13)
+local v2 = v0 + v1;
+v2.Print();
+
+FakeNamespace <- {
+	Utils = {}
+}
+
+class FakeNamespace.Utils.SuperClass {
+	constructor()
+	{
+		::print("FakeNamespace.Utils.SuperClass")
+	}
+}
+
+local testy = FakeNamespace.Utils.SuperClass();
\ No newline at end of file