1 module orelang.operator.CarOperator;
2 import orelang.operator.IOperator,
3        orelang.Engine,
4        orelang.Value;
5 import std.conv;
6 
7 class CarOperator : 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       Value[] obx = obj.getArray;
16 
17       if (obx.length >= 1) {
18         return obx[0];
19       } else {
20         throw new Exception("pair required, but got ()");
21       }
22     } else {
23       throw new Exception("pair required, but got invalid data, the type of which is " ~ obj.type.to!string);
24     }
25   }
26 }