# Syntax of exchanging values of 2 variables seems to be broken in short-circuit evaluation

**URL:** <https://discourse.julialang.org/t/syntax-of-exchanging-values-of-2-variables-seems-to-be-broken-in-short-circuit-evaluation/76125>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 9, 2022, 10:44pm UTC](https://discourse.julialang.org/t/syntax-of-exchanging-values-of-2-variables-seems-to-be-broken-in-short-circuit-evaluation/76125 "2022-02-09T22:44:56Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Jollywatt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jollywatt/32/202198_2.png) [@Jollywatt](https://discourse.julialang.org/u/Jollywatt)\
**Post date:** [February 9, 2022, 11:40pm UTC](https://discourse.julialang.org/t/syntax-of-exchanging-values-of-2-variables-seems-to-be-broken-in-short-circuit-evaluation/76125/4 "2022-02-09T23:40:13Z")

</div>

This is because of [named tuple syntax](https://discourse.julialang.org/t/named-tuples-construction-unpacking/51074).

Notice `(t1, t2 = (t2, t1))` is short for `(t1 = t1, t2 = (t2, t1))` and results in `NamedTuple{(:t1, :t2)}((t1, (t2, t1)))`.

So you’ll need to disambiguate a (named) tuple literal from a `()`-grouped expression. You could do this like so:

```julia
true && ((t1, t2) = (t2, t1)) # an expression, not a tuple, since no comma

true && begin # explicit block
    t1, t2 = t2, t1
end

```

So this isn’t a bug — just confusion about Julia’s (very carefully designed) syntax!

---

_[View the full topic](https://discourse.julialang.org/t/syntax-of-exchanging-values-of-2-variables-seems-to-be-broken-in-short-circuit-evaluation/76125)._
