Ruby’s Right Ward Assignment

variableName = variableValue
variableValue => variableName

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.

Functionality

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
a = b == c
a <- b == c
a <- 5 -> b

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.

--

--

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