ArtLung

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.

posted this 15 years ago.
What else did he post in February 2007?

(Wednesday February 21st 2007 at 8:20pm)

Leave me a comment!

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