blob: 80eeeaf004acdf519bf3a2525886e61e1ab1c4cc [file] [log] [blame]
package main
import (
"fmt"
"reflect"
)
func makeSwap(fptr interface{}) {
swap := func(in []reflect.Value) []reflect.Value {
return []reflect.Value{in[1], in[0]}
}
fn := reflect.ValueOf(fptr).Elem()
v := reflect.MakeFunc(fn.Type(), swap)
fn.Set(v)
}
func main() {
var fn func(int, int) (int, int)
makeSwap(&fn)
fmt.Println(fn(0, 1))
}