Standard library / reflect

reflect.Value.SetIterKey()

Assigns the current iterator key to a settable compatible destination without constructing a separate Key Value. Expected stdout: 'a\n'.

Formal Syntax & Structure

go syntaxgo
func (v Value) SetIterKey(iter *MapIter)

Parameters & Attributes

NameTypeDescription
iter*MapIterIterator positioned at a valid map entry.

Working Example

Example Snippetgo
package main
import (  "fmt"  "reflect")
func main() {  m := reflect.ValueOf(map[string]int{"a": 7})  it := m.MapRange()  it.Next()  var k string  reflect.ValueOf(&k).Elem().SetIterKey(it)  fmt.Println(k)}
Go Reference