]> Cypherpunks repositories - gostls13.git/commit
container/list: make Remove return Value of removed element.
authorRoger Peppe <rogpeppe@gmail.com>
Tue, 9 Nov 2010 16:58:23 +0000 (08:58 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 9 Nov 2010 16:58:23 +0000 (08:58 -0800)
commite9afb9d399125e3f8bcda135913905ff3a3a6b5e
treef13d10ca1cddce6295310491923c2327b4608741
parent9626180918d834e0a6eb56e28c6ca201e39dbcba
container/list: make Remove return Value of removed element.
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
src/pkg/container/list/list.go