Is there any internal mechanism that convert the accessing key of dictionary to a specific function?

2010-08-12 Fir de Conversatie winterTTr
I mean if there is such mechanism in the vim script itself. OK, maybe the title of this mail is not very clear for you to understand, i just give an example. let foo = {} let foo.var = 100 we can access the value 100 by : echo foo.var echo foo['var'] i just want to know if there is a mechanism

Re: Is there any internal mechanism that convert the accessing key of dictionary to a specific function?

2010-08-12 Fir de Conversatie Ingo Karkat
On 12-Aug-2010 10:19, winterTTr wrote: I mean if there is such mechanism in the vim script itself. OK, maybe the title of this mail is not very clear for you to understand, i just give an example. let foo = {} let foo.var = 100 we can access the value 100 by : echo foo.var echo

Re: Is there any internal mechanism that convert the accessing key of dictionary to a specific function?

2010-08-12 Fir de Conversatie Jürgen Krämer
Hi, Ingo Karkat wrote: On 12-Aug-2010 10:19, winterTTr wrote: Or is there an alternate method to accessing dictionary when the key is not found , instead of showing error directly? You can use echo get(foo, 'var', MyFunction('var')) MyFunction() can then return whatever you want

Re: Is there any internal mechanism that convert the accessing key of dictionary to a specific function?

2010-08-12 Fir de Conversatie winterTTr
On 12 August 2010 17:01, Jürgen Krämer jottka...@googlemail.com wrote: Hi, Ingo Karkat wrote: On 12-Aug-2010 10:19, winterTTr wrote: Or is there an alternate method to accessing dictionary  when the key is not found , instead of showing error directly? You can use     echo get(foo,

Re: Is there any internal mechanism that convert the accessing key of dictionary to a specific function?

2010-08-12 Fir de Conversatie Ben Fritz
On Aug 12, 4:23 am, winterTTr winterttr@gmail.com wrote: OK, thanks so much for your answers.  I do not notice the get() method. There is indeed an alternate way to do so. That's great. However, I must use this code everywhere if i want the feature as i mentioned. Even the other person

Re: Is there any internal mechanism that convert the accessing key of dictionary to a specific function?

2010-08-12 Fir de Conversatie winterTTr
On 12 August 2010 20:34, Ben Fritz fritzophre...@gmail.com wrote: On Aug 12, 4:23 am, winterTTr winterttr@gmail.com wrote: OK, thanks so much for your answers.  I do not notice the get() method. There is indeed an alternate way to do so. That's great. However, I must use this code