Last active
August 29, 2015 14:13
-
-
Save agalera/8b13ebc8816623f4a650 to your computer and use it in GitHub Desktop.
default values in ruby
This file contains 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
#check python https://gist.github.com/kianxineki/aa10199ba96d0d4009c6 | |
def append_values(new_value,a=[]) | |
a.push(new_value) | |
return a | |
end | |
append_values("n1") # result ['n1'] | |
rlist = append_values("n2") # result ['n2'] | |
rlist.push("n3") | |
print rlist # result ['n2', 'n3'] | |
append_values("n3") # result ['n3'] | |
append_values("n4", []) # result ['n4'] | |
append_values("n5") # result ['n5'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment