示例#1
0
        public static object Is(this FObject obj, ObjType t)
        {
            switch (obj.Type)
            {
            case FObjectType.Int when t == ObjType.Number:
                return(obj.I64);

            case FObjectType.Float when t == ObjType.Number:
                return(obj.F64);

            case FObjectType.Array when t == ObjType.Array:
                return(obj.Array());

            case FObjectType.String when t == ObjType.String:
                return(obj.ToString());

            case FObjectType.Bool when t == ObjType.Bool:
                return(obj.BOOL);

            default:
                throw new Exception($"Not able to cast {obj.Type} to a {t} ");
            }
        }