[Array] replace: [Number] length: [Number] with: [Array]. | Manual
[Array] replace: [Number] length: [Number] with: [Array].
Returns a copy of the array with the specified elements replaced.
The first argument indicates the start index to begin the replacement.
Here, 0 means the beginning of the array. The second argument (length)
must indicate the number of elements to delete in the copy, counting
from the starting point. Finally, one has to provide the replacement
array as the third argument.
If the replacement array is empty, the specified elements will only be
removed from the copy.
If the replacement is not an array an error will be thrown.
☞ cakes := Array ← 'apple' ; 'berry' ; 'choco' ; 'cheese'. #apple, cinnamon, pineapple, cheese ☞ buy := cakes replace: 1 length: 2 with: ( Array ← 'cinnamon' ; 'pineapple' ). #apple, cinnamon, pineapple ☞ buy := cakes replace: 1 length: 12 with: ( Array ← 'cinnamon' ; 'pineapple' ). #apple, berry ☞ buy := cakes replace: 2 length: 10 with: ( Array new ). #berry, choco, cheese ☞ buy := cakes replace: '' length: '1' with: ( Array new ). #error... ☞ buy := cakes replace: '' length: '1' with: 'x'.
Welcome to the Citrine Online Manual Pages. This online manual has been generated automatically from source code comments using the shtml.ctr script. All Citrine documentation is also available as a UNIX manual file included in the download package. These pages are just a web version of the original Citrine Programming Language User Manual and Reference Guide.
Improve this manual
You can help to improve this manual. Any help is appreciated! If you spot an error in this manual or you want to contribute, just change the corresponding comment in the original Citrine Programming Language source code hosted on github and create a 'Pull Request'. After the documentation generation script has been invoked again the manual pages will be updated to reflect your contribution and so will these online manual pages.
Citrine is an easy to use programming language for everyone. Citrine is so simple it does not even need special syntax for loops or conditions. You can learn Citrine in just a couple of minutes. Citrine makes programming fun again! Visit the homepage for a quick tutorial.