feat: add DropRight and DropWhile

This commit is contained in:
dudaodong committed 2023-02-09 17:38:31 +08:00
1 parent afb021b4b5
commit 040e112aa6
3 files changed
+75 -13

No files matched your search

+18
View File
@@ -482,7 +482,25 @@ func ExampleDrop() {
// Output:
// [a b c]
// [b c]
// [a b c]
// []
}
func ExampleDropRight() {
result1 := DropRight([]string{"a", "b", "c"}, 0)
result2 := DropRight([]string{"a", "b", "c"}, 1)
result3 := DropRight([]string{"a", "b", "c"}, -1)
result4 := DropRight([]string{"a", "b", "c"}, 4)
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
// Output:
// [a b c]
// [a b]
// [a b c]
// []
}