Last active
April 25, 2016 15:59
-
-
Save arturoherrero/9984405d559f50a12e530dcaeb7ba706 to your computer and use it in GitHub Desktop.
Comparing Array.push, Array.concat and Array.+= Ruby behaviour
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
a = [1,2,3] # => [1, 2, 3] | |
b = [4,5] # => [4, 5] | |
a.object_id # => 70128600052080 | |
a += b # => [1, 2, 3, 4, 5] | |
[a, b] # => [[1, 2, 3, 4, 5], [4, 5]] | |
a.object_id # => 70128599818940 |
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
a = [1,2,3] # => [1, 2, 3] | |
b = [4,5] # => [4, 5] | |
a.object_id # => 70128600052080 | |
a += b # => [1, 2, 3, 4, 5] | |
[a, b] # => [[1, 2, 3, 4, 5], [4, 5]] | |
a.object_id # => 70128600052080 |
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
a = [1,2,3] # => [1, 2, 3] | |
b = [4,5] # => [4, 5] | |
a.object_id # => 70128600052080 | |
a += b # => [1, 2, 3, 4, 5] | |
[a, b] # => [[1, 2, 3, 4, 5], [4, 5]] | |
a.object_id # => 70128600052080 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment