.drop()
MarkDGraham1 total contribution
Published Nov 6, 2023
Contribute to Docs
The .drop()
method removes characters from the start (0th index) of a given string to the nth index element.
Syntax
String.drop(nth-index)
String
: The string to be modified. The method will return a new string with the specified values missing.nth-index
: The method will remove characters up to this value.
Example
The example demonstrates the use of .drop()
to remove characters from the beginning of the string.
fun main() {val str = "This is new"val str2 = "I'm a string"println(str.drop(8)) // Drops 'This is 'println(str2.drop(6)) // Drops 'I'm a '}
The output of the code above will be:
newstring
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.