When I discovered that python has parallel assignment I thought is pretty cool.
Recently I discovered parallel assignment works also in ruby.
For people that don’t know it: x,y = y,x
in ruby, python this swaps x and y values .
Which language came first with parallel assignment, python? or was it other language?
11
CPL introduced the feature in 1963, calling it simultaneous assignment. From D.W. Barron et al., “The main features of CPL” (page 140):
24. Simultaneous assignment commands
The general form of an assignment command can now be given. Normally this is an expression yielding an LH value, followed by :=, followed by an expression yielding an RH value. However, if an explicit list is written on the left-hand side then the right-hand side is either an explicit list, or a list expression; in the latter case the transfer function Members is automatically invoked. In this form the two explicit lists must contain the same number of members, and the command denotes a simultaneous assignment of each right-hand member to the corresponding left-hand member. Thus, if L is a list variable and a, b, c are real variables,
L := a, b, c
is an assignment to the list variable, while
a, b, c := L
a, b := b,a
are simultaneous assignments.
1