February
9th,
2012
I found myself today in the opportunity to use a double association in a ternary operator. Basically I wanted to assign 2 variables based on a certain condition. Normal ruby double assignment works easy like this:
Up to here no surprise. But what if I want to evaluate a condition and assigns both the variables??
Both this attempts ends in a syntax error. The right way:
Easy and clean. Values comes in an array and are correctly assigned. Of course this works for any number of variables you need to assign