A class that stores an expression you can execute.
    public class Expression : Reference

An expression can be made of any arithmetic operation, built-in math function call, method call of a passed instance, or built-in type construction call.

An example expression text using the built-in math functions could be sqrt(pow(3,2) + pow(4,2)).

In the following example we use a LineEdit node to write our expression and show the result.


onready var expression = Expression.new()

func _ready():

$LineEdit.connect(“text_entered”, self, “_on_text_entered”)

func _on_text_entered(command):

var error = expression.parse(command, [])

if error != OK:



var result = expression.execute([], null, true)

if not expression.has_execute_failed():

$LineEdit.text = str(result)


Inheritance Chain


    public Expression()


    public object Execute(Godot.Collections.Array inputs = null, Object baseInstance = null, bool showError = true)

Executes the expression that was previously parsed by Parse(string, string[]) and returns the result. Before you use the returned object, you should check if the method failed by calling HasExecuteFailed().

If you defined input variables in Parse(string, string[]), you can specify their values in the inputs array, in the same order.

    public string GetErrorText()

Returns the error text if Parse(string, string[]) has failed.

    public bool HasExecuteFailed()

Returns true if Execute(Godot.Collections.Array, Godot.Object, bool) has failed.

    public Error Parse(string expression, string[] inputNames = null)

Parses the expression and returns a [enum @GlobalScope.Error].

You can optionally specify names of variables that may appear in the expression with inputNames, so that you can bind them when it gets executed.