This is both for variables and objects but since strings floats and integers are actually objects in ruby you re always assigning objects.
Ruby switch case assignment.
As of ruby 1 6 2 if an assignment has one lvalue and multiple rvalues the rvalues are converted to an array and assigned to the lvalue.
Whenever you need to use some if elsif statements you could consider using a ruby case statement instead.
In programming languages a switch statement is a type of control mechanism used to check if the value of a variable or expression exists and what the program should do from that point.
If a multiple assignment contains more rvalues than lvalues the extra rvalues are ignored.
It takes the variables that will be used by when keyword.
In ruby it is implemented using the case argument.
It is similar to the case keyword in another programming languages.
Parallel assignment in ruby.
There can be multiple when statements into a single case statement.
You can collapse and expand arrays using ruby s parallel assignment operator.
The components of a case statement in ruby.
Case as switch statement in ruby with parameter.
In most computer languages the case or conditional also known as switch statement compares the value of a variable with that of several constants or literals and executes the first path with a matching case in ruby it s a bit more flexible and powerful.
In other programming languages this is known as a switch statement.
Case equality case subsumption or three equals operator.
Assignment in ruby is done using the equal operator.