Skip to content

Commit

Permalink
Fix the behaviour of Array#[]= with [start, length]
Browse files Browse the repository at this point in the history
  • Loading branch information
nrk committed Apr 14, 2009
1 parent 90071f9 commit 7b819d6
Showing 1 changed file with 12 additions and 2 deletions.
Expand Up @@ -408,8 +408,17 @@ public static class IListOps {
DeleteItems(self, index, length);
} else {
if (valueAsList == null) {
SetElement(context, self, index, value);
Insert(context, self, index, value);

if (length > 0) {
RemoveRange(self, index + 1, Math.Min(length, self.Count - index - 1));
}
} else {
if (value == self) {
valueAsList = new object[self.Count];
self.CopyTo(valueAsList as object[], 0);
}

ExpandList(self, index);

int limit = length > valueAsList.Count ? valueAsList.Count : length;
Expand All @@ -420,7 +429,8 @@ public static class IListOps {

if (length < valueAsList.Count) {
InsertRange(self, index + limit, EnumerateRange(valueAsList, limit, valueAsList.Count - limit));
} else {
}
else {
RemoveRange(self, index + limit, Math.Min(length - valueAsList.Count, self.Count - (index + limit)));
}
}
Expand Down

0 comments on commit 7b819d6

Please sign in to comment.