Mercurial > vim
diff runtime/doc/eval.txt @ 17667:95c23e180022
Update runtime files.
commit https://github.com/vim/vim/commit/088e8e3443520dec91a384081e66445a104810bb
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 8 22:15:18 2019 +0200
Update runtime files.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 08 Aug 2019 22:30:08 +0200 |
parents | da7890e3359b |
children | 06c3e15ad84d |
line wrap: on
line diff
--- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 8.1. Last change: 2019 Aug 04 +*eval.txt* For Vim version 8.1. Last change: 2019 Aug 08 VIM REFERENCE MANUAL by Bram Moolenaar @@ -4396,15 +4396,24 @@ function({name} [, {arglist}] [, {dict}] the Funcref and will be used when the Funcref is called. The arguments are passed to the function in front of other - arguments. Example: > + arguments, but after any argument from |method|. Example: > func Callback(arg1, arg2, name) ... - let Func = function('Callback', ['one', 'two']) + let Partial = function('Callback', ['one', 'two']) ... - call Func('name') + call Partial('name') < Invokes the function as with: > call Callback('one', 'two', 'name') +< With a |method|: > + func Callback(one, two, three) + ... + let Partial = function('Callback', ['two']) + ... + eval 'one'->Partial('three') +< Invokes the function as with: > + call Callback('one', 'two', 'three') + < The function() call can be nested to add more arguments to the Funcref. The extra arguments are appended to the list of arguments. Example: > @@ -6196,6 +6205,8 @@ map({expr1}, {expr2}) *map()* call map(myDict, {key, val -> key . '-' . val}) < If you do not use "val" you can leave it out: > call map(myDict, {key -> 'item: ' . key}) +< If you do not use "key" you can use a short name: > + call map(myDict, {_, val -> 'item: ' . val}) < The operation is done in-place. If you want a |List| or |Dictionary| to remain unmodified make a copy first: > @@ -10120,6 +10131,11 @@ It is also possible to use `:eval`. It allow for method chaining, e.g.: > eval GetList()->Filter()->append('$') +A function can also be called as part of evaluating an expression or when it +is used as a method: > + let x = GetList() + let y = GetList()->Filter() + AUTOMATICALLY LOADING FUNCTIONS ~ *autoload-functions*