Created
December 16, 2015 15:49
-
-
Save LolWalid/feacc676a304ff477e33 to your computer and use it in GitHub Desktop.
All is 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
| # toute donnée est un objet, y compris les types ; | |
| # toute fonction est une méthode ; | |
| # toute variable est une référence à un objet ; | |
| a = [1, 2, 3] | |
| b = a | |
| a << 4 | |
| b | |
| def add(array, x) | |
| array << x | |
| end | |
| def double(array) | |
| array.map! { |e| e * 2 } | |
| end | |
| add(a, 42) | |
| a | |
| double(a) | |
| a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment