Skip to content

List.Remove behaves weird #1224

@gopherbot

Description

@gopherbot

by kees.varekamp:

Example: 
package main 
import ( 
        "container/list" 
        "fmt" 
) 
func main() { 
        l := list.New() 
        l.PushBack("A") 
        l.PushBack("B") 
        e := l.Front() 
        l.Remove(e) 
        fmt.Printf("len:%d list:%v\n",l.Len(),l) 
        l.Remove(e) 
        fmt.Printf("len:%d list:%v\n",l.Len(),l) 
} 

Output: 
len:1 list:&{0xb772b3c0 0xb772b3c0 1 0xb770d7f8} 
len:0 list:&{<nil> <nil> 0 0xb770d7f8} 
We're thinking the first Remove should remove e from the list, then 
the second should do nothing. But it seems to remove the next first 
element.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions