doc: add docstrings for String.drop and String.dropRight (#7607)
This PR adds docstrings for `String.drop` and `String.dropRight`.
This commit is contained in:
parent
131b458236
commit
7e1ee70b7c
1 changed files with 20 additions and 0 deletions
|
|
@ -1414,9 +1414,29 @@ end Substring
|
|||
|
||||
namespace String
|
||||
|
||||
/--
|
||||
Removes the specified number of characters (Unicode code points) from the start of the string.
|
||||
|
||||
If `n` is greater than `s.length`, returns `""`.
|
||||
|
||||
Examples:
|
||||
* `"red green blue".drop 4 = "green blue"`
|
||||
* `"red green blue".drop 10 = "blue"`
|
||||
* `"red green blue".drop 50 = ""`
|
||||
-/
|
||||
@[inline] def drop (s : String) (n : Nat) : String :=
|
||||
(s.toSubstring.drop n).toString
|
||||
|
||||
/--
|
||||
Removes the specified number of characters (Unicode code points) from the end of the string.
|
||||
|
||||
If `n` is greater than `s.length`, returns `""`.
|
||||
|
||||
Examples:
|
||||
* `"red green blue".dropRight 5 = "red green"`
|
||||
* `"red green blue".dropRight 11 = "red"`
|
||||
* `"red green blue".dropRight 50 = ""`
|
||||
-/
|
||||
@[inline] def dropRight (s : String) (n : Nat) : String :=
|
||||
(s.toSubstring.dropRight n).toString
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue