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] > <javascript:>> 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] >> <javascript:>> 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] <javascript:>> >>> 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 >>>> >>>> >>>> >>> >> >
