"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/builtin/array.pony" between
ponyc-0.33.1.tar.gz and ponyc-0.33.2.tar.gz

About: Pony is an object-oriented, actor-model, capabilities-secure, high performance programming language.

array.pony  (ponyc-0.33.1):array.pony  (ponyc-0.33.2)
skipping to change at line 341 skipping to change at line 341
if i < _size then if i < _size then
_ptr._update(i, consume value) _ptr._update(i, consume value)
else else
error error
end end
fun ref insert(i: USize, value: A) ? => fun ref insert(i: USize, value: A) ? =>
""" """
Insert an element into the array. Elements after this are moved up by one Insert an element into the array. Elements after this are moved up by one
index, extending the array. index, extending the array.
An out of bounds index raises an error.
When inserting right beyond the last element, at index `this.size()`,
the element will be appended, similar to `push()`,
an insert at index `0` prepends the value to the array.
An insert into an index beyond `this.size()` raises an error.
```pony
let array = Array[U8](4) // []
array.insert(0, 0xDE)? // prepend: [0xDE]
array.insert(array.size(), 0xBE)? // append: [0xDE; 0xBE]
array.insert(1, 0xAD)? // insert: [0xDE; 0xAD; 0xBE]
array.insert(array.size() + 1, 0xEF)? // error
```
""" """
if i <= _size then if i <= _size then
reserve(_size + 1) reserve(_size + 1)
_ptr._offset(i)._insert(1, _size - i) _ptr._offset(i)._insert(1, _size - i)
_ptr._update(i, consume value) _ptr._update(i, consume value)
_size = _size + 1 _size = _size + 1
else else
error error
end end
 End of changes. 1 change blocks. 
1 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)