Standard library / reflect

reflect.Value.SetIterValue()

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

Formal Syntax & Structure

go syntaxgo
func (v Value) SetIterValue(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 x int  reflect.ValueOf(&x).Elem().SetIterValue(it)  fmt.Println(x)}
Go Reference