Difference between revisions of "Insert"

From MiniScript Wiki
Jump to navigation Jump to search
(Created page with "<c>insert</c> inserts a new element into a string or list. See also: remove === Arguments === {| class="wikitable" |- ! Parameter Name !! Default Value !! Meaning |- |...")
 
Line 26: Line 26:
 
[[Category:List Methods]]
 
[[Category:List Methods]]
 
[[Category:String Methods]]
 
[[Category:String Methods]]
[[Category:Map Methods]]
 
[[Category:Numeric Functions]]
 

Revision as of 15:23, 17 March 2020

insert inserts a new element into a string or list.

See also: remove

Arguments

Parameter Name Default Value Meaning
self string or list sequence to insert into
index number position at which to insert the new item
value any element to insert at the specified index

Usage Notes

In the case of a list, the list is both modified in place and returned. Strings are immutable, so in that case the original string is unchanged, but a new string is returned with the value inserted.

Example

"Hello".insert(2, 42)		// returns "He42llo"