// Assign will assign the specified value to the variable
Assign will assign the specified value to the variable
// Assign will assign the specified value to the variable
func (e *Variable) Assign(newVal reflect.Value, dataContext IDataContext, memory *WorkingMemory) error {
	if len(e.Name) > 0 && e.Variable == nil {
		err := dataContext.Add(e.Name, pkg.ValueToInterface(newVal))
		if err == nil {
			dataContext.IncrementVariableChangeCount()
		}
		return err
	}
	if e.Variable != nil && len(e.Name) > 0 {
		_, err := e.Variable.Evaluate(dataContext, memory)
		if err != nil {
			return err
		}
		err = e.Variable.ValueNode.SetObjectValueByField(e.Name, newVal)
		if err == nil {
			dataContext.IncrementVariableChangeCount()
			memory.ResetVariable(e)
		}
		return err
	}
	if e.Variable != nil && e.ArrayMapSelector != nil {
		_, err := e.Variable.Evaluate(dataContext, memory)
		if err != nil {
			return err
		}
		_, err = e.ArrayMapSelector.Evaluate(dataContext, memory)
		if err != nil {
			return err
		}
		if e.Variable.ValueNode.IsArray() {
			err := e.Variable.ValueNode.SetArrayValueAt(int(e.ArrayMapSelector.Value.Int()), newVal)
			if err == nil {
				memory.ResetVariable(e)
			}
			return err
		}
		if e.Variable.ValueNode.IsMap() {
			err := e.Variable.ValueNode.SetMapValueAt(e.ArrayMapSelector.Value, newVal)
			if err == nil {
				memory.ResetVariable(e)
			}
			return err
		}
	}
	return fmt.Errorf("this code part should not be reached")
}
func ( e * Variable ) Assign ( newVal reflect . Value , dataContext IDataContext , memory * WorkingMemory ) error { if len ( e . Name ) > 0 && e . Variable == nil { err := dataContext . Add ( e . Name , pkg . ValueToInterface ( newVal ) ) if err == nil { dataContext . IncrementVariableChangeCount ( ) } return err } if e . Variable != nil && len ( e . Name ) > 0 { _ , err := e . Variable . Evaluate ( dataContext , memory ) if err != nil { return err } err = e . Variable . ValueNode . SetObjectValueByField ( e . Name , newVal ) if err == nil { dataContext . IncrementVariableChangeCount ( ) memory . ResetVariable ( e ) } return err } if e . Variable != nil && e . ArrayMapSelector != nil { _ , err := e . Variable . Evaluate ( dataContext , memory ) if err != nil { return err } _ , err = e . ArrayMapSelector . Evaluate ( dataContext , memory ) if err != nil { return err } if e . Variable . ValueNode . IsArray ( ) { err := e . Variable . ValueNode . SetArrayValueAt ( int ( e . ArrayMapSelector . Value . Int ( ) ) , newVal ) if err == nil { memory . ResetVariable ( e ) } return err } if e . Variable . ValueNode . IsMap ( ) { err := e . Variable . ValueNode . SetMapValueAt ( e . ArrayMapSelector . Value , newVal ) if err == nil { memory . ResetVariable ( e ) } return err } } return fmt . Errorf ( " " ) }
Assign will assign the specified value to the variable
Assign will assign the specified value to the variable