Created
November 14, 2011 10:19
-
-
Save dcarley/1363673 to your computer and use it in GitHub Desktop.
Ruby silently unpacks vars to nil, then interpolates to "".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dan@dan-MacPro:~$ python unpack.py | |
| foo: foo | |
| bar: bar | |
| dan@dan-MacPro:~$ ruby unpack.rb | |
| foo: foo | |
| bar: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try: | |
| foo, bar = ["foo"] | |
| except: | |
| foo, bar = ["foo", "bar"] | |
| print "foo: %s" % foo | |
| print "bar: %s" % bar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin | |
| foo, bar = ["foo"] | |
| rescue | |
| foo, bar = ["foo", "bar"] | |
| end | |
| puts "foo: #{foo}" | |
| puts "bar: #{bar}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment