Sunday, January 17, 2021

Re: vim9script: dump file content to list of list question !

Hi,

Ni Va schrieb am 15.01.2021 um 14:38:
>
> I got this kind of classical logfile :
>
> 2021/01/14 07:42:22.588 InformationFoo dbg 
> 2021/01/14 07:42:22.588 InformationBar dbg 
> 2021/01/14 07:42:22.588 Information    Foobar dbg 
> 2021/01/14 07:42:22.588 Information    Barbar dbg 
> ..
> .
>
> and would like to add all lines' informations split by space into dict or array in vim9script.
> ['2021/01/14', '07:42:22.588', 'Information  Foo dbg   ']
>
> trying map(getline(1, '$'), ' v:val->split() ') it returns list<list<string>> but impossible to declare var foo: list<list<string>>
>
> How can I fix it ?

you need to use mapnew() instead of map(), because the item type changes.

getline() returns a list of strings. The supplied expression would replace
every item of type string by an item of type list<string>. In Vim9 script
this is not allowed. Instead you need to use mapnew() which creates a new
list which is then filled with the results of the mapping expression.

Regards,
Jürgen

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5faab10b-5dc8-4b39-f5f9-b8f87da6f4ef%40googlemail.com.

No comments:

Post a Comment