1 module orelang.operator.LengthOperator;
2 import orelang.operator.IOperator,
3        orelang.Engine,
4        orelang.Value;
5 import std.conv;
6 
7 class LengthOperator : IOperator {
8   /**
9    * call
10    */
11   public Value call(Engine engine, Value[] args) {
12     Value obj = engine.eval(args[0]);
13 
14     if (obj.type == ValueType.Array) {
15       return new Value(obj.getArray.length.to!double);
16     } else {
17       throw new Exception("Given object is not an Array or List");
18     }
19   }
20 }