Skip to content

Instantly share code, notes, and snippets.

@kalabiyau
Created March 21, 2013 09:21
Show Gist options
  • Save kalabiyau/5211758 to your computer and use it in GitHub Desktop.
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
>> [[]] * 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