Hi Tim!

On Di, 13 Okt 2009, Tim Chase wrote:

> >     let b[word]=(exists("b[word]")?b[word]+1:1
> 
> This can be more clea[rn]ly written as
> 
>    let b[word]=get(b, word, 0) + 1

Thanks. I first tried let b[word]+=1, but this didn't work, so this was 
my 2nd try. Thanks for pointing that out.

> which gets "b[word]" if it exists, or defaults to 0 if it 
> doesn't.  (It's a retweaking of a Python idiom "b.get(word,0)" as 
> a lot of the list/dict stuff in Vim seems to be influenced by 
> Python's syntax)

Yeah, looks like this.


regards,
Christian
-- 
:wq

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to