Search notes:

vim script: function

function(…) creates a funcref.
" ..\run_ function
"
" see also -> call()

redir > function.out

fu! F_sum(n1, n2) " {
  return a:n1 + a:n2
endfu " }

fu! F_mult(n1, n2) " {
  return a:n1 * a:n2
endfu " }

let FuncRef_1 = function('F_sum' )
let FuncRef_2 = function('F_mult')

echo FuncRef_1(10, 32)
" 42

echo FuncRef_2( 7,  6)
" 42
"
" Using -> call() {

let s:args = [10, 15]
echo call(FuncRef_1, s:args)
" 25

" }

" Special case: define a function and assign a funcref to a dictionary entry {

let SomeHash = {'ix-1': 'one', 'ix-2': 'two'}

fu SomeHash.funcName(arg) dict
   return 2*a:arg
endfu

echo join(keys(SomeHash), ' / ')
" ix-2 / funcName / ix-1

echo SomeHash['funcName'](21)
" 42

" }

redir END
q
Github repository about-vim, path: /vimscript/functions/function.vim

See also

Vim: built in functions
VIM script

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758184124, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/vim/script/vimscript/functions/function(92): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78