Created
March 21, 2013 09:21
-
-
Save kalabiyau/5211758 to your computer and use it in GitHub Desktop.
If you like splat operator, you should know that you will get same object when utilizing splat to populate Array
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
>> [[]] * 5 | |
=> [[], [], [], [], []] | |
>> _.each {|e| puts e.object_id} | |
19154620 | |
19154620 | |
19154620 | |
19154620 | |
19154620 | |
=> [[], [], [], [], []] | |
>> [Array.new] * 5 | |
=> [[], [], [], [], []] | |
>> _.each {|e| puts e.object_id} | |
25876020 | |
25876020 | |
25876020 | |
25876020 | |
25876020 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment