question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Difference between SetConstant and Scope.Add

See original GitHub issue

Hello,

I tried the following code


 Engine engine = new Engine();
 //engine.Scope.Add("time", 17);
 engine.SetConstant("time", 17);
 var result = engine.Interpret("(time > 12 ? (time - 12) + \" pm\" : time + \" am\")");

If I use Scope I get (unknown) am as the result If I use SetConstant I get the correct result as 5 pm

What are the differences Between these 2 methods, when do we use one over the other? I was wondering why SetConstant worked while Scope did not?

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
TomasaMullercommented, Jan 19, 2023

I did set it correctly with an int data type like this

No you did not. Int32 is not a native type. You should make it 17.0, as Double (called Number) is a native type in Mages.

Please look at the documentation.

Yes I just replied a fraction of a second ago. Apologies !

0reactions
FlorianRapplcommented, Jan 19, 2023

All good! Hope everything now works as it should!

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Defining Constants by Scope
A common reasoning against globals, singletons, etc. is that the scope of everything should be limited as far as (reasonably) possible.
Read more >
JavaScript const
Block Scope. Declaring a variable with const is similar to let when it comes to Block Scope. The x declared in the block,...
Read more >
Built-In Operators
The atxd operators add another geometry to the current product. Suppose, for example, that you have a 2D base geometry with scope comp1,...
Read more >
Class IloObjective
An objective consists of its sense (specifying whether it is a minimization or maximization) and an expression. The expression may be a constant,...
Read more >
Model House Heating System - MATLAB & Simulink
The simulation validates the expected behavior. Remove Constant, Step, and Scope blocks you added for testing the Heater component.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found