Loading ...
Sorry, an error occurred while loading the content.

101985Re: for [k,v] in items(dict): Bug? Design?

Expand Messages
  • Maxim Kim
    Mar 2, 2009
      > Just tried:
      >
      > let lst = ["hello", []]
      > for value in lst
      > endfor
      >
      > Gives me the same error.
      > I'd expect it to do :unlet key, :unlet value before each iteration.

      He he.
      Note on :h for made it clear.

      >>Note that the type of each list item should be
      >>identical to avoid errors for the type of {var}
      >>changing. Unlet the variable at the end of the loop
      >>to allow multiple item types.

      I have to unlet variables explicitly:
      let lst = ["hello", []]
      for value in lst
      unlet value
      endfor

      This is inconvenient but usable. :)

      Just curious, why for loop implemented that way?
      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Show all 3 messages in this topic