All posts

Set multiple variables to a single value using Ruby or Elixir

To accomplish this you set each variable you need to have the same value on the same line like so:

variable3 = variable2 = variable1 = "the famous cats"

Now each of the variables above will be equal to “the famous cats”

=> variable3
"the famous cats"
=> variable2
"the famous cats"
=> variable1
"the famous cats"

From there you can overwrite each variable when/if needed.

Check out other Elixir and Ruby posts: