I am a RoR developer and want to clarify some doubt about ruby variable assignment.In ruby we have two ways for variable assignment.str, arr, num = Hi, [1, 2], 3andstr = Hiarr = [1, 2]num = 3I know that the first way will go slower than second way but, I want to know that as per ruby language, which way is preferable and performance reliable?
What is faster and preferable way for variable assignment in ruby?
performance;coding standards;ruby;ruby on rails;standards
Writing Efficient Ruby Code by Dr. Stefan Kaes has this to say about parallel assignment (your first example):Like any other Ruby expression, a value needs to be returned from a  parallel assignment. The value returned by a parallel assignment is  the value of the expression on the right-hand side of the assignment.  This means Ruby needs to create an array if the right-hand side is a  list of expressions:$ irb>> a,b = 1,2=> [1, 2]Of course, if the assignment isnt the last statement of a method, the  created array becomes garbage immediately. Its therefore advisable to  avoid the use of parallel assignment in performance-critical code  sections.Dr. Kaes goes on to speculate that Ruby 1.9 may change the semantics of parallel assignments to always return true for performance reasons.To my eye, parallel assignment aids neither clarity nor maintainability, so, performance reasons aside, I would avoid it as a matter of course.