If v is in s, I wanted first to pop v out of s out and second increase a 
counter. But you're right I can use delete! and then compare length if 
needed.

On Friday, October 23, 2015 at 12:48:08 PM UTC-4, Stefan Karpinski wrote:
>
> I'd rather have it be correct than incorrect and fast so I fixed it first. 
> I also just don't understand the rationale for the method existing in the 
> first place. If you pop something from a set you should get that value 
> back. What use is supplying a default? If you just want to remove the value 
> unconditionally, you can do delete!(s, v).
>
> On Fri, Oct 23, 2015 at 12:38 PM, Matt <[email protected] <javascript:>> 
> wrote:
>
>> Thanks! 
>> I thought it was a more efficient version than 
>> if key in x
>>  pop!(x, key)
>> end
>> So yeah this method is not really useful if it is actually the same.
>>
>> I'm curious: isn't there some inefficiency in first testing for the key 
>> and then popping it out?
>>
>> On Friday, October 23, 2015 at 11:32:42 AM UTC-4, Stefan Karpinski wrote:
>>>
>>> Fixed: 
>>> https://github.com/JuliaLang/julia/commit/4164572c53b7c18888ddb104a196d87558576031
>>>
>>> On Fri, Oct 23, 2015 at 10:51 AM, Stefan Karpinski <[email protected]
>>> > wrote:
>>>
>>>> It's also a little unclear to me what this method is useful for.
>>>>
>>>> On Fri, Oct 23, 2015 at 8:53 AM, Stefan Karpinski <[email protected]
>>>> > wrote:
>>>>
>>>>> Ah, this is a bug in that pop! method. I'm working on a fix.
>>>>>
>>>>> On Fri, Oct 23, 2015 at 8:42 AM, Matt <[email protected]> wrote:
>>>>>
>>>>>> I want to check if a key is in a set, and pop! it if it is the case.
>>>>>>
>>>>>>
>>>>>> 1. In order to do that, I can rely on a try / catch statement (i.e. 
>>>>>> try pop!(x, key)) or a default key (i.e. pop!(x, key, nothing)). Is one 
>>>>>> preferable to the other in term of speed?
>>>>>>
>>>>>> 2.. pop!(x, key, nothing) returns nothing even if key is in x. Is 
>>>>>> this expected?
>>>>>>
>>>>>>
>>>>>> nothing == pop!(Set(1:2), 2, nothing)
>>>>>>
>>>>>> true
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>

Reply via email to