There is also a DefaultDict implementation in DataStructures.jl which has
semantics close to your desired example.

(On my phone, so an example is hard to provide, sorry.)

Cheers,
   Kevin

On Saturday, December 20, 2014, Jacob Quinn <[email protected]> wrote:

> Firstly, I believe `dict["b"]++` assumes that the key would be defaulted
> to 0, then incremented. Currently, `getindex` and `setindex` don't allow
> setting default values, that can be achieved through
>
> `get(dict, "b", 0)`
>
> Secondly, `++` is not an actual operator in Julia.
> You can achieve what you're trying to do with:
>
> dict["a"] = 1
> dict["b"] = 0
> dict["b"] += 1
>
> You'll have to clarify your question if that doesn't help.
>
> -Jacob
>
>
>
> On Sat, Dec 20, 2014 at 8:52 PM, Min-Woong Sohn <[email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote:
>
>> dict = Dict()
>> dict["a"] = 1
>> 1
>> dict["b"] ++
>>
>> key not found: "b"
>>
>>
>> This behavior is surprising and potentially very limiting. Is there any 
>> discussion on this?
>>
>>
>

Reply via email to