Last active
December 16, 2015 16:49
-
-
Save mumumu/5465691 to your computer and use it in GitHub Desktop.
difference of keyword arguments between Ruby 2.0.0 and Python.
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
mumumu@www 17:12:11$ python | |
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) | |
[GCC 4.4.5] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> def test(a = []): | |
... a.append(10) | |
... print a | |
... | |
>>> test() | |
[10] | |
>>> test() | |
[10, 10] | |
>>> test() | |
[10, 10, 10] | |
>>> test() | |
[10, 10, 10, 10] | |
---- | |
mumumu@www 17:11:26$ ruby --version | |
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux] | |
mumumu@www 17:11:35$ irb | |
irb(main):001:0> def test(a = []) | |
irb(main):002:1> a.push(10) | |
irb(main):003:1> end | |
=> nil | |
irb(main):004:0> test | |
=> [10] | |
irb(main):005:0> test | |
=> [10] | |
irb(main):006:0> test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment