-
Notifications
You must be signed in to change notification settings - Fork 0
/
pop.go
44 lines (34 loc) · 842 Bytes
/
pop.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package golist
import "github.com/emylincon/golist/core"
// Pop :
// removes element in list using index and returns it
func (arr *List) Pop(index int) interface{} {
switch list := arr.list.(type) {
case []int:
var popped int
arr.list, popped = core.PopInt(&list, index)
return popped
case []int32:
var popped int32
arr.list, popped = core.PopInt32(&list, index)
return popped
case []int64:
var popped int64
arr.list, popped = core.PopInt64(&list, index)
return popped
case []float32:
var popped float32
arr.list, popped = core.PopFloat32(&list, index)
return popped
case []float64:
var popped float64
arr.list, popped = core.PopFloat64(&list, index)
return popped
case []string:
var popped string
arr.list, popped = core.PopString(&list, index)
return popped
default:
return nil
}
}