collections - Does pop throw an exception or not? -


The doctor says for the

pop function:

  Users & gt; (Doctor Pop) ------------------------- clojure.core / pop ([coll]) For a list or queue, a new list / Without the first item, the queue gives a new vector for a vector, without the last item, if the collection is empty, then an exception throws   

However, I do not regenerate that behavior Where an exception should be thrown.

For example, if I add three elements to the queue then pop five times: According to the doctor, this should not work though, instead of being an exception, I get zero.

  (pick (pop (pop (pop (pop (cose (angle (conj cloor lung presist cue / AMPT4) 5) 6)))))))) < / Code>  

Now I like that rather than throwing an empty queue back exception instead of pop empty queue but I want to understand why the behavior is different from the doctor (less Less than what I understand by reading the docs).

Actually I would like to know that I should protect myself here with one exception or if I can safely believe that pop is always a blank line ( Which is opposing the doctor) will return.

You are right, you see a paradox in the doctor string. Currently, popping a blank queue gives an empty queue. It would appear that major developers were debating the behavior desired by comments:

  public continuous quote pop () {if (f == null ) // Hmmm ... pop up the empty queue - & gt; Empty the queue? This return; // Throw new invalidstate abatement (to move "empty line"); ISEK F1 = F.X (); Continuous vector R1 = R; If (F1 == is empty) {F1 = RT.Sec (R); R1 = Faucet; } Return new Persistentue (Meta (), CNT1, F1, R1); }   

I do not think it's safe to believe that this behavior will never be changed in the future.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -