premise
foo = 'foo'
bar = 'bar'
Way that Uses tmp variable(Normal way)
tmp = foo
foo = bar
bar = tmp
Multi Assignment
Merit
- no tmp
- 3rows to 1row of the switch logic
- The switch intention became clear.
foo, bar = bar, foo
# => [
# [0] "bar",
# [1] "foo"
# ]
foo # => "bar"
bar # => "foo"
π Multiassign(ja)
Top comments (0)