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:


I built two products to help fund continued efforts for this website, it would mean a lot if you would check them out:
1. 2500+ Words for the Undermotivated Software Engineer - A short essay I wrote on the titled topic ($3).
2. Build 3 Chrome Extensions in Under 2 Hours - A course I built to teach chrome extension development ($9-20).