nicklockwood / Expression

A cross-platform Swift library for evaluating mathematical expressions at runtime
MIT License
829 stars 51 forks source link

when using the sample code it won't execute #31

Closed AWS-Drew closed 3 years ago

AWS-Drew commented 3 years ago

the sample code cut from the description: var bar = 7 // variable let expression = Expression("bas + baz(5) + rnd()", symbols: [ .variable("bar"): { in bar }, .function("baz", arity: 1): { args in args[0] as! Int + 1 }, .function("rnd", arity: 0): { in Double(arc4random()) } ])

Has this issue: "Type of expression is ambiguous without more context" "Expression" is imported

nicklockwood commented 3 years ago

Are you also importing Foundation in the same file? Foundation also defines an Expression type.

AWS-Drew commented 3 years ago

In the view controller I have 4 imports....uikit, charts, Darwin, and expression

Sent from my iPad

On Feb 26, 2021, at 1:17 PM, Nick Lockwood notifications@github.com wrote:

 Are you also importing Foundation in the same file? Foundation also defines an Expression type.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

AWS-Drew commented 3 years ago

But I do have foundation called up in another file

Sent from my iPad

On Feb 26, 2021, at 1:22 PM, Drew Swenson n171ml@yahoo.com wrote:

In the view controller I have 4 imports....uikit, charts, Darwin, and expression

Sent from my iPad

On Feb 26, 2021, at 1:17 PM, Nick Lockwood notifications@github.com wrote:

 Are you also importing Foundation in the same file? Foundation also defines an Expression type.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

AWS-Drew commented 3 years ago

Finally figured it out. When cutting and pasting to try out the code, “Expression” was just not being recognized. However, when typing it in, the format was instantly recognized

Sent from my iPad

On Feb 26, 2021, at 1:17 PM, Nick Lockwood notifications@github.com wrote:

 Are you also importing Foundation in the same file? Foundation also defines an Expression type.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.