mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
Updated InterfaceSlice (markdown)
parent
8b01addc5a
commit
8ae9118961
@ -36,7 +36,7 @@ If you really want a ` []interface{} ` because you'll be doing indexing before c
|
|||||||
```go
|
```go
|
||||||
var dataSlice []int = foo()
|
var dataSlice []int = foo()
|
||||||
var interfaceSlice []interface{} = make([]interface{}, len(dataSlice))
|
var interfaceSlice []interface{} = make([]interface{}, len(dataSlice))
|
||||||
for i, d := range dataSlice {
|
for i := range dataSlice {
|
||||||
interfaceSlice[i] = d
|
interfaceSlice[i] = dataSlice[i]
|
||||||
}
|
}
|
||||||
```
|
```
|
Loading…
x
Reference in New Issue
Block a user