package com.github.basking2.sdsai.itrex.packages;

import com.github.basking2.sdsai.itrex.functions.DictFunction;
import com.github.basking2.sdsai.itrex.functions.FunctionInterface;

import java.util.Map;

public class DictPackage {
    public static final FunctionInterface<Map<Object, Object>> dict = new DictFunction();
    public static final FunctionInterface<Object> dictGet = (args, ctx) -> {
        final Map<Object, Object> m = (Map<Object, Object>)args.next();
        return m.get(args.next());
    };
    public static final FunctionInterface<Map<Object, Object>> dictPut = (args, ctx) -> {
        final Map<Object, Object> m = (Map<Object, Object>)args.next();
        final Object key = args.next();
        final Object val = args.next();
        m.put(key, val);
        return m;
    };
}

@@ -469,42 +469,251 @@
 ();%0A
-        return m.get(args.next());
+%0A        final Object key = args.next();%0A%0A        if (m.containsKey(key)) %7B%0A            return m.get(key);%0A        %7D%0A        else if (args.hasNext()) %7B%0A            return args.next();%0A        %7D%0A        else %7B%0A            return null;%0A        %7D
 %0A   

Allow dictGet to have a default value.