Difference between revisions of "Insert"

From MiniScript Wiki
Jump to navigation Jump to search
m (Links)
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
<c>insert</c> inserts a new element into a [[string]] or [[list]].
 
<c>insert</c> inserts a new element into a [[string]] or [[list]].
  
See also: [[remove]]
+
See also: [[push]]; [[remove]]
  
 
=== Arguments ===
 
=== Arguments ===

Latest revision as of 23:20, 30 July 2022

insert inserts a new element into a string or list.

See also: push; 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"