I'm trying to understand the code suggested in https://vi.stackexchange.com/a/28506/6189:
function MyLinks(pat, spat, ssub, sflags) abort
return glob(a:pat, v:false, v:true)
\ ->map({_, v -> printf('[%s](%s)', fnamemodify(v, ':t:r')->substitute(a:spat, a:ssub, a:sflags), fnamemodify(v, ':t'))})
\ ->join("\n")
endfunction
...and this map({_,...
syntax confuses me.
:h map()
says: map({expr1}, {expr2})
and states: "Replace each item in {expr1} with the result of evaluating {expr2}".
So map is using the input from glob(...)
as its first argument, and this {long..bunch..of..stuff}
is the second argument. That makes sense. But "long bunch of stuff" begins with {_,
. What is that? What is _
?