Expand the documentation of setv
This commit is contained in:
parent
627455a336
commit
1e77f38d10
@ -424,20 +424,19 @@ For example:
|
|||||||
=> (counter [1 2 3 4 5 2 3] 2)
|
=> (counter [1 2 3 4 5 2 3] 2)
|
||||||
2
|
2
|
||||||
|
|
||||||
They can be used to assign multiple variables at once:
|
You can provide more than one target–value pair, and the assignments will be made in order::
|
||||||
|
|
||||||
.. code-block:: hy
|
(setv x 1 y x x 2)
|
||||||
|
(print x y) ; => 2 1
|
||||||
|
|
||||||
=> (setv a 1 b 2)
|
You can perform parallel assignments or unpack the source value with square brackets and :ref:`unpack-iterable`::
|
||||||
(1L, 2L)
|
|
||||||
=> a
|
|
||||||
1L
|
|
||||||
=> b
|
|
||||||
2L
|
|
||||||
=>
|
|
||||||
|
|
||||||
|
(setv duo ["tim" "eric"])
|
||||||
|
(setv [guy1 guy2] duo)
|
||||||
|
(print guy1 guy2) ; => tim eric
|
||||||
|
|
||||||
``setv`` always returns ``None``.
|
(setv [letter1 letter2 #* others] "abcdefg")
|
||||||
|
(print letter1 letter2 others) ; => a b ['c', 'd', 'e', 'f', 'g']
|
||||||
|
|
||||||
|
|
||||||
setx
|
setx
|
||||||
|
Loading…
x
Reference in New Issue
Block a user