# What Does \`:=\` Do?

**URL:** <https://discourse.julialang.org/t/what-does-do/59957>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [April 24, 2021, 10:15pm UTC](https://discourse.julialang.org/t/what-does-do/59957 "2021-04-24T22:15:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [April 24, 2021, 10:15pm UTC](https://discourse.julialang.org/t/what-does-do/59957/1 "2021-04-24T22:15:03Z")

</div>

What the title says. I can’t figure it out, and the docs just provide the not at all useful description:  
`x := y is a synonym for x = x : y`

Which apparently means something different from what I expected to, given the following returns an error rather than a range:

```julia
julia> x = 2
2

julia> y = 4
4

julia> x:=y

```

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [April 24, 2021, 10:22pm UTC](https://discourse.julialang.org/t/what-does-do/59957/2 "2021-04-24T22:22:50Z")

</div>

> [@ParadaCarleton](#):
>
> What the title says. I can’t figure it out, and the docs just provide the not at all useful description:  
> `x := y is a synonym for x = x : y`

That’s actually an error in the docs that I believe was recently fixed. `:=` doesn’t do anything. It’s basically just reserved syntax for macros.

E.g. some people want domain specific languages embedded in julia might have a syntax like

```julia
@model begin
    x := 1
    y := x + 1
    ...
end

```

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [April 24, 2021, 10:23pm UTC](https://discourse.julialang.org/t/what-does-do/59957/3 "2021-04-24T22:23:04Z")

</div>

Can you link to the docs? That is not valid syntax in `1.*`.

---

<div class="post-metadata">

**Author:** ![ParadaCarleton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paradacarleton/32/20005_2.png) [@ParadaCarleton](https://discourse.julialang.org/u/ParadaCarleton)\
**Post date:** [April 24, 2021, 10:24pm UTC](https://discourse.julialang.org/t/what-does-do/59957/4 "2021-04-24T22:24:26Z")

</div>

Interesting – what are some examples of macros that use this?

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [April 24, 2021, 10:25pm UTC](https://discourse.julialang.org/t/what-does-do/59957/5 "2021-04-24T22:25:16Z")

</div>

Here’s what I get in the `help>` mode in 1.6:

```julia
help?> :=
search:

  x := y is a synonym for x = x : y

```

This note gets automatically generated for a bunch of infix operators but was done erroneously for `:`.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [April 24, 2021, 10:25pm UTC](https://discourse.julialang.org/t/what-does-do/59957/6 "2021-04-24T22:25:40Z")

</div>

[https://github.com/HarrisonGrodin/Rewrite.jl](https://github.com/HarrisonGrodin/Rewrite.jl)
