V: Unable to get keys from immutable map

Created on 19 Sep 2019  路  4Comments  路  Source: vlang/v

V version: 0.1.20 c8a781b
OS: Win 10 1809

What did you do?
Maps related REPL

What did you expect to see?

>>> wang:={'1':2,'3':4}
>>> wang.keys()
["1", "3"]

What did you see instead?

>>> mut miao:={'1':2,'3':4}
>>> miao.keys()
["1", "3"]
>>> wang:={'1':2,'3':4}
>>> wang.keys()
C:\Program Files\v\.vrepl_temp.v:4:18: `wang` is immutable, declare it with `mut`
Bug

Most helpful comment

Like the docs say, " will be supported too.

All 4 comments

By the way, in addition to the bug described, why the output is ["1", "3"] and not ['1', '3']? Double quote is 'illegal caracter' in V, so why do we output the result in "illegal" way? :)

Of course, in general I would urge (again?) to rethink usage of single and double quotes in V for string literals in general, as double quotes are much more common in programming languages for strings with interpolation. But this should be put in a separate issue. Sorry. :)

Like the docs say, " will be supported too.

" is now supported :) @avitkauskas

Fixed @wh-timme

Was this page helpful?
0 / 5 - 0 ratings

Related issues

medvednikov picture medvednikov  路  3Comments

taojy123 picture taojy123  路  3Comments

ArcDrake picture ArcDrake  路  3Comments

penguindark picture penguindark  路  3Comments

markgraydev picture markgraydev  路  3Comments