Standard library / reflect
reflect.Value.Slice3()
Returns a three-index slice view with capacity limited by the third index; it does not work on strings. Expected stdout: '1 2\n'.
Formal Syntax & Structure
go syntaxgo
func (v Value) Slice3(i, j, k int) ValueParameters & Attributes
| Name | Type | Description |
|---|---|---|
| i | int | Zero-based index, or the input interface value for TypeOf and ValueOf. |
| j | int | Exclusive upper index. |
| k | int | Exclusive capacity bound for three-index slicing. |
Return Value
Value
Returns a three-index slice view with capacity limited by the third index; it does not work on strings.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { s := reflect.ValueOf([]int{1, 2, 3}) r := s.Slice3(0, 1, 2) fmt.Println(r.Len(), r.Cap())}