Mercurial > vim
comparison runtime/doc/eval.txt @ 17387:2558f90045e5 v8.1.1692
patch 8.1.1692: using *{} for literal dict is not backwards compatible
commit https://github.com/vim/vim/commit/b8be54dcc517c9d57b62409945b7d4b90b6c3071
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 14 18:22:59 2019 +0200
patch 8.1.1692: using *{} for literal dict is not backwards compatible
Problem: Using *{} for literal dict is not backwards compatible. (Yasuhiro
Matsumoto)
Solution: Use ~{} instead.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 14 Jul 2019 18:30:04 +0200 |
parents | 6604ecb7a615 |
children | 40417757dffd |
comparison
equal
deleted
inserted
replaced
17386:b46cfa993bcf | 17387:2558f90045e5 |
---|---|
58 | 58 |
59 Dictionary An associative, unordered array: Each entry has a key and a | 59 Dictionary An associative, unordered array: Each entry has a key and a |
60 value. |Dictionary| | 60 value. |Dictionary| |
61 Examples: | 61 Examples: |
62 {'blue': "#0000ff", 'red': "#ff0000"} | 62 {'blue': "#0000ff", 'red': "#ff0000"} |
63 *{blue: "#0000ff", red: "#ff0000"} | 63 ~{blue: "#0000ff", red: "#ff0000"} |
64 | 64 |
65 Funcref A reference to a function |Funcref|. | 65 Funcref A reference to a function |Funcref|. |
66 Example: function("strlen") | 66 Example: function("strlen") |
67 It can be bound to a dictionary and arguments, it then works | 67 It can be bound to a dictionary and arguments, it then works |
68 like a Partial. | 68 like a Partial. |
480 String automatically. Thus the String '4' and the number 4 will find the same | 480 String automatically. Thus the String '4' and the number 4 will find the same |
481 entry. Note that the String '04' and the Number 04 are different, since the | 481 entry. Note that the String '04' and the Number 04 are different, since the |
482 Number will be converted to the String '4'. The empty string can also be used | 482 Number will be converted to the String '4'. The empty string can also be used |
483 as a key. | 483 as a key. |
484 *literal-Dict* | 484 *literal-Dict* |
485 To avoid having to put quotes around every key the *{} form can be used. This | 485 To avoid having to put quotes around every key the ~{} form can be used. This |
486 does require the key to consist only of ASCII letters, digits, '-' and '_'. | 486 does require the key to consist only of ASCII letters, digits, '-' and '_'. |
487 Example: > | 487 Example: > |
488 let mydict = *{zero: 0, one_key: 1, two-key: 2, 333: 3} | 488 let mydict = ~{zero: 0, one_key: 1, two-key: 2, 333: 3} |
489 Note that 333 here is the string "333". Empty keys are not possible here. | 489 Note that 333 here is the string "333". Empty keys are not possible here. |
490 | 490 |
491 A value can be any expression. Using a Dictionary for a value creates a | 491 A value can be any expression. Using a Dictionary for a value creates a |
492 nested Dictionary: > | 492 nested Dictionary: > |
493 :let nestdict = {1: {11: 'a', 12: 'b'}, 2: {21: 'c'}} | 493 :let nestdict = {1: {11: 'a', 12: 'b'}, 2: {21: 'c'}} |