I have an array filled with default strings, and I'm trying to replace a part of the characters in the default string at a random position. 

If I do something like this, I will have all elements in the array changed:

```
arr = ["*"] * 10
arr[0][0..2] = "aaa"
arr 
# => ["aaa", "aaa", "aaa", "aaa", "aaa", "aaa", "aaa", "aaa", "aaa", "aaa"]

```

But if I initialize an array in a different way, it works:

```
(0..10).each.map {|i| arr[i] = "*"}
arr[0][0..2] = "aaa"
arr
# => ["aaa", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*"]

```

Some more, initialize and all elements same: 

```
str = "*"
(0..10).each.map {|i| arr[i] = str}
arr[0][0..2] = "aaa"
arr
# => ["aaa", "aaa", "aaa", "aaa", "aaa", "aaa", "aaa", "aaa", "aaa", "aaa"]

```

Instead i did this to initialize it with unique elements: 

```
str = "*"
(0..10).each.map {|i| arr[i] = "#{str}" }
arr[0][0..2] = "aaa"
arr
# => ["aaa", "*", "*", "*", "*", "*", "*", "*", "*", "*"]

```

What is the background for such behavior?