=. The names take the
values in the order they were returned, and the count must match.
return [a, b, c]. The elements may have different types.
Built-in tuples
talib.macd(source, fastlen, slowlen, siglen) returns [macd, signal, histogram]. talib.bb(source, length, mult),
talib.kc(source, length, mult) and talib.dc(length) return [middle, upper, lower]. talib.dmi(diLength, adxSmoothing) returns
[plusDI, minusDI, adx] and talib.supertrend(multiplier, atrLength) returns [supertrend, direction]. Unpack them as above.
For many values of one type, return an array<float> (see Arrays); for several named values, a
type of your own (see Custom types and enums).
Reassign and the rules
[a, b] := f()assigns to names that already exist;[a, b] = f()declares them, and repeating it for existing names is an error.- A tuple cannot be stored in one variable, and
[a, b]is only valid as a function result or an argument, not on the right of=. - Tuples do not nest.
The mistakes to avoid
Unpacking the wrong number of names gives: Number of variables on the left side of the assignment operator does not match the number of elements in the tuple on the right side. Expected: 2, Got: 3. And[1] after the call is the history operator, which a tuple
does not accept: History Indexing not allowed on tuple expression. Unpack first, then index the name you unpacked.
See Your own functions.