Skip to content

How to cast(or convert) to some type ? #77

Open
@Himmelt

Description

@Himmelt

Hello!

Dictionary<string, Func<object>> varMap = new() {
    ["sec"] = () => DateTime.Now.Second
};

var calc = Funny.WithFunction("vars", (string name) => varMap[name]()).BuildForCalcConstant();

var result = calc.Calc("1 + vars('sec')");

Console.WriteLine(result);

These codes will cause NFun.Exceptions.FunnyParseException:“Invalid operator call argument: +(T0, T0)->T0. Expected: T0”.

I want to cast or convert the object{int} type to integer or real type, but I didn't found the usage in the examples.

Can you show me how to do this ?

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    Help/QuestionA question the answer to which may help other users in the future

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions