• Roger Peppe's avatar
    container/list: make Remove return Value of removed element. · e9afb9d3
    Roger Peppe authored
    When it is known that there is already at least one element in the
    list, it is awkwardly verbose to use three lines and an extra
    variable declaration to remove the first or last item (a common
    case), rather than use a simple expression.
    
    a stack:
    	stk.PushFront(x)
    	x = stk.Front().Remove().(T)
    
    vs.
    	stk.PushFront(x)
    	e := stk.Front()
    	e.Remove()
    	x = e.Value.(T)
    [An alternative CL might be to add PopFront and PopBack methods].
    
    R=gri
    CC=golang-dev
    https://golang.org/cl/3000041
    e9afb9d3
list.go 4.79 KB