Standard library / reflect
reflect.AppendSlice()
Appends the elements of a slice with the same element type, returning the resulting slice. Expected stdout: '[1 2 3 4 5]\n'.
Formal Syntax & Structure
go syntaxgo
func AppendSlice(s, t Value) ValueParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | Value | Destination slice value. |
| t | Value | Source slice with the same element type as the destination. |
Return Value
Value
Appends the elements of a slice with the same element type, returning the resulting slice.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { s := reflect.ValueOf([]int{1, 2, 3}) fmt.Println(reflect.AppendSlice(s, reflect.ValueOf([]int{4, 5})).Interface())}