What does the second example for map() mean?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

What does the second example for map() mean?

Benjamin R. Haskell-8
There's an example in the help for map() that reads:

:let tlist = map(copy(mylist), ' & . "\t"')

What is that ampersand doing there?  Is the example incomplete?
Obsolete?  Should it be v:val instead?

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: What does the second example for map() mean?

Chris Jones-44
On Tue, Jun 26, 2012 at 09:56:48PM EDT, Benjamin R. Haskell wrote:

> There's an example in the help for map() that reads:
>
> :let tlist = map(copy(mylist), ' & . "\t"')
>
> What is that ampersand doing there?  Is the example incomplete?
> Obsolete?  Should it be v:val instead?

Yes. Looks like someone was making quick changes to the doc and used ‘&’
to recall the last match and somehow, a literal ampersand ended up in
there instead...

Now.. How's that for guesswork? :-)

CJ

--
Alex Perez is aliveeeeeeee!!!

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: What does the second example for map() mean?

Jan Larres
Chris Jones <[hidden email]>:

> On Tue, Jun 26, 2012 at 09:56:48PM EDT, Benjamin R. Haskell wrote:
>> There's an example in the help for map() that reads:
>>
>> :let tlist = map(copy(mylist), ' & . "\t"')
>>
>> What is that ampersand doing there?  Is the example incomplete?
>> Obsolete?  Should it be v:val instead?
>
> Yes. Looks like someone was making quick changes to the doc and used ‘&’
> to recall the last match and somehow, a literal ampersand ended up in
> there instead...

From looking at the commit logs it seems that rather an '&' is what was
originally used for substituting in the current value, and then got
replaced by 'v:val' a bit later. This line seems to have been
overlooked. I'll send a patch to vim-dev.

Jan

--
-[ OpenPGP key ID: 00A0FD5F ]-
The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" (I found it!) but "That's funny ..."
                -- Isaac Asimov

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php