Method: Cons#pop

Defined in:
lib/cons.rb

#popObject

The pop method reads the value of place, remembers the car of the list which was retrieved, writes the cdr of the list back into the place, and finally yields the car of the originally retrieved list.

Cf. <clhs.lisp.se/Body/m_pop.htm>



308
309
310
311
312
313
314
# File 'lib/cons.rb', line 308

def pop
  result = @car
  n = @cdr
  @car = n.car
  @cdr = n.cdr
  return result
end