diff runtime/doc/eval.txt @ 26638:6fd15d82e898 v8.2.3848

patch 8.2.3848: cannot use reduce() for a string Commit: https://github.com/vim/vim/commit/0ccb5842f5fb103763d106c7aa364d758343c35a Author: rbtnn <naru123456789@gmail.com> Date: Sat Dec 18 18:33:46 2021 +0000 patch 8.2.3848: cannot use reduce() for a string Problem: Cannot use reduce() for a string. Solution: Make reduce() work with a string. (Naruhiko Nishino, closes https://github.com/vim/vim/issues/9366)
author Bram Moolenaar <Bram@vim.org>
date Sat, 18 Dec 2021 19:45:03 +0100
parents 3a63b1e4a6f4
children 7c055fdd6200
line wrap: on
line diff
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -8959,9 +8959,9 @@ readfile({fname} [, {type} [, {max}]])
 
 reduce({object}, {func} [, {initial}])			*reduce()* *E998*
 		{func} is called for every item in {object}, which can be a
-		|List| or a |Blob|.  {func} is called with two arguments: the
-		result so far and current item.  After processing all items
-		the result is returned.
+		|String|, |List| or a |Blob|.  {func} is called with two arguments:
+		the result so far and current item.  After processing all
+		items the result is returned.
 
 		{initial} is the initial result.  When omitted, the first item
 		in {object} is used and {func} is first called for the second
@@ -8972,6 +8972,7 @@ reduce({object}, {func} [, {initial}])		
 			echo reduce([1, 3, 5], { acc, val -> acc + val })
 			echo reduce(['x', 'y'], { acc, val -> acc .. val }, 'a')
 			echo reduce(0z1122, { acc, val -> 2 * acc + val })
+			echo reduce('xyz', { acc, val -> acc .. ',' .. val })
 <
 		Can also be used as a |method|: >
 			echo mylist->reduce({ acc, val -> acc + val }, 0)