Last active
August 29, 2015 14:21
-
-
Save ArgonCode/f2e4f7dfb241ba4f69a4 to your computer and use it in GitHub Desktop.
Pass by value vs. pass by reference
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
2.2.2 :001 > var1 = "hello" | |
=> "hello" | |
2.2.2 :002 > var2 = var1 | |
=> "hello" | |
2.2.2 :004 > var2.upcase | |
=> "HELLO" | |
2.2.2 :005 > var2 | |
=> "hello" | |
2.2.2 :006 > var1 | |
=> "hello" | |
2.2.2 :007 > var2.upcase! | |
=> "HELLO" | |
2.2.2 :008 > var1 | |
=> "HELLO" | |
2.2.2 :009 > var2 | |
=> "HELLO" | |
2.2.2 :001 > var1 = :symbol | |
=> :symbol | |
2.2.2 :002 > var2 = var1 | |
=> :symbol | |
2.2.2 :003 > var1.to_s | |
=> "symbol" | |
2.2.2 :004 > var1 | |
=> :symbol | |
2.2.2 :005 > var2 | |
=> :symbol | |
2.2.2 :006 > var1 = var1.to_s | |
=> "symbol" | |
2.2.2 :007 > var2 | |
=> :symbol | |
2.2.2 :008 > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment