Skip to content

Instantly share code, notes, and snippets.

@nixsticks
Created December 6, 2013 01:32
Show Gist options
  • Select an option

  • Save nixsticks/7817200 to your computer and use it in GitHub Desktop.

Select an option

Save nixsticks/7817200 to your computer and use it in GitHub Desktop.
string1 = "arrays are mutable"
string2 = "and so are strings"
string3 = "did you know?"
array1 = [string1, string2, string1]
array1[0] << " and so are strings"
array1
# You're probably expecting array1 to return ["arrays are mutable and so are strings", "and so are strings", "arrays are mutable"], right?
# NOPE. The result is:
[
[0] "arrays are mutable and so are strings",
[1] "and so are strings",
[2] "arrays are mutable and so are strings"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment