cbdeveloper
cbdeveloper

Reputation: 31495

Trying to reference previous value during series variable assignment?

I would like to do the following:

thisSeries = 
  someCondition ? 1 
  : someOtherCondition ? -1 
    : thisSeries[1]

What I need is to repeat the previousValue: thisSeries[1] if neither conditions are met.

I'm getting the error:

Undeclared identifier 'thisSeries'

How can I do this?

Upvotes: 0

Views: 153

Answers (1)

alexgrover
alexgrover

Reputation: 1043

Since the v2, any variable using recursion must be declared beforehand.

thisSeries = 0
thisSeries := someCondition ? 1 : someOtherCondition ? -1 : thisSeries[1]

First, the variable is declared as an integer, then we redeclare it using the assignment operator :=.

Upvotes: 2

Related Questions