Ruby’s Right Ward Assignment

There is a feature that was being experimented on in ruby which is the “Right-ward Assignment Operator”.

By current day standard, we assign values to variable using a “left”-ward assignment operator. Where the variable is on the left, and the value is on the right.

variableName = variableValue

This new feature reverse that operator and allows us to switch the direction where the value on the left, and and variable name is on the right.

variableValue => variableName

For a lot of programmers this might seem backwards and make it harder to read code. Especially for JavaScript programmers who use arrow functions daily. However I can see this becoming very useful for beginner programmers or non programmers since this method of assigning variables is the structure on how Math is used.

The History

One of the more used coding language R also allowed right-ward assignment, which comes from S which was inspired by APL. In fact APL was designed on a specific keyboard which had a button for <-. Back then the = symbol was used for testing equality (We now use ==). So they had to use a different symbol so they used the special key <- as assignment operator.


Before 2001, the <- was the standard method to assign value into variable. Even after = symbol was introduced, it is advised in R coding guides to use <- since it clearly states which side you are making the assignment to (You can assign from both side in R).

 a <- 5
6 -> b

It is also easier to distinguish comparison and assignment when the two are used within the same line of code.

a = b == c
a <- b == c

Another interesting use of the <- assignment is that you can use it to assign to multiple variables at the same time.

a <- 5 -> b

Which isn’t doable with just = symbol.

Ruby’s Right Ward Assignment

As of this moment, ruby is only experimenting with right-ward assignment variables. We don’t know if ruby will end up keeping this functionality or not, but it is a interesting method to code.

If anything, since ruby already have so many methods that does the same task, why not include more and just give the users the ability to choose whichever method they prefer. I’m definitely happy to see ruby adding more functionalities whether they are the most common practice or not.



Just a student at flatiron

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store