patch 9.0.1515: reverse() does not work for a String
Problem: reverse() does not work for a String.
Solution: Implement reverse() for a String. (Yegappan Lakshmanan,
closes #12179)
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index dd68006..beb7ac7 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -484,7 +484,8 @@
repeat({expr}, {count}) List/Blob/String
repeat {expr} {count} times
resolve({filename}) String get filename a shortcut points to
-reverse({list}) List reverse {list} in-place
+reverse({obj}) List/Blob/String
+ reverse {obj}
round({expr}) Float round off {expr}
rubyeval({expr}) any evaluate |Ruby| expression
screenattr({row}, {col}) Number attribute at screen position
@@ -7404,11 +7405,13 @@
GetName()->resolve()
reverse({object}) *reverse()*
- Reverse the order of items in {object} in-place.
- {object} can be a |List| or a |Blob|.
- Returns {object}.
- Returns zero if {object} is not a List or a Blob.
- If you want an object to remain unmodified make a copy first: >
+ Reverse the order of items in {object}. {object} can be a
+ |List|, a |Blob| or a |String|. For a List and a Blob the
+ items are reversed in-place and {object} is returned.
+ For a String a new String is returned.
+ Returns zero if {object} is not a List, Blob or a String.
+ If you want a List or Blob to remain unmodified make a copy
+ first: >
:let revlist = reverse(copy(mylist))
< Can also be used as a |method|: >
mylist->reverse()