Ernie Rael wrote:
> >>>> In vim9.txt there's
> >>>>
> >>>> The key type can be string, number, bool or float.=C2=A0 Other types r=
> es> ult in an
> >>>> error.=C2=A0 A number can be given with and without the []:
> >>>>
> >>>> Don't know if the following shows a bug in implementation or documenta=
> ti> on.
> >>>> The two dictionaries are not equal.
> >>>>
> >>>> =C2=A0=C2=A0=C2=A0 vim9script
> >>>>
> >>>> =C2=A0=C2=A0=C2=A0 var d1 =3D {[000123]: 'foo'}
> >>>> =C2=A0=C2=A0=C2=A0 echo d1
> >>>> =C2=A0=C2=A0=C2=A0 ### output {'123': 'foo'}
> >>>>
> >>>> =C2=A0=C2=A0=C2=A0 var d2 =3D {000123: 'foo'}
> >>>> =C2=A0=C2=A0=C2=A0 echo d2
> >>>> =C2=A0=C2=A0=C2=A0 ### output {'000123': 'foo'}
> >>>>
> >>>> =C2=A0=C2=A0=C2=A0 if d1 =3D=3D d2
> >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 echo 'EQUAL'
> >>>> =C2=A0=C2=A0=C2=A0 else
> >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 echo 'NOT EQUAL'
> >>>> =C2=A0=C2=A0=C2=A0 endif
> >>> This is correct. The key eventually is always a string. If you use a
> >>> number and convert it to a string then leading zeros are dropped. If
> >>> you use a string with leading zeros, they are kept. This is in the hel=
This should be clearer:
The key type can be string, number, bool or float. Other types result in an
error. Without using [] the value is used as a string, keeping leading zeros.
An expression given with [] is evaluated and then converted to a string.
Leading zeros will then be dropped: >
var dict = {000123: 'without', [000456]: 'with'}
echo dict
{'456': 'with', '000123': 'without'}
--
hundred-and-one symptoms of being an internet addict:
91. It's Saturday afternoon in the middle of May and you
are on computer.