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
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.