Destructured Assignment in Ruby, PHP, and JavaScript

Stupid Code Tricks:

Ruby http://www.ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/syntax.html#assign

foo, bar = [1, 2]

PHP http://www.php.net/manual/en/function.list.php

list($foo, $bar) = array(1, 2);

JavaScript http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7#Destructuring_assignment

[foo, bar] = [1, 2];  // I believe this is only valid in the latest versions of Firefox.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.