Navigation

Operators and Keywords

Function List:

C++ API

: [r1, r2, …, rn] = deal (a)
: [r1, r2, …, rn] = deal (a1, a2, …, an)

Copy the input parameters into the corresponding output parameters.

If only a single input parameter is supplied, its value is copied to each of the outputs.

For example,

[a, b, c] = deal (x, y, z);

is equivalent to

a = x;
b = y;
c = z;

and

[a, b, c] = deal (x);

is equivalent to

a = b = c = x;

Programming Note: deal is often used with comma separated lists derived from cell arrays or structures. This is unnecessary as the interpreter can perform the same action without the overhead of a function call. For example:

c = {[1 2], "Three", 4};
[x, y, z] = c{:}
⇒
   x =

      1   2

   y = Three
   z =  4

See also: cell2struct, struct2cell, repmat.

Package: octave