# What's the difference between variable binding and assignment?

**URL:** <https://forum.elixirforum.com/t/whats-the-difference-between-variable-binding-and-assignment/4971>\
**Category:** Questions\
**Tags:** immutability\
**Created:** [May 7, 2017, 6:02am UTC](https://forum.elixirforum.com/t/whats-the-difference-between-variable-binding-and-assignment/4971 "2017-05-07T06:02:00Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![smpallen99](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/smpallen99/32/1157_2.png) [@smpallen99](https://forum.elixirforum.com/u/smpallen99)\
**Post date:** [May 10, 2017, 4:27am UTC](https://forum.elixirforum.com/t/whats-the-difference-between-variable-binding-and-assignment/4971/8 "2017-05-10T04:27:22Z")

</div>

The code you showed works. However, we usually try to reduce the number of single use variables. So, the “Elixir way” of writing that code is

```
var1 = 
  123
  |> get_new_value(:something)
  |> get_new_value(:something2)

```

Furthermore, if it was the last statement in a function, then we would drop the var1 like this:

```
def my_fun do
  # ...
  123
   |> get_new_value(:something)
   |> get_new_value(:something2)
end

```

---

_[View the full topic](https://forum.elixirforum.com/t/whats-the-difference-between-variable-binding-and-assignment/4971)._
