mirror of
https://github.com/traefik/yaegi.git
synced 2026-06-01 18:37:56 +00:00
The case of assigning a binary function to a funcT object was solved elsewhere. Factor the case in genDestValue to apply it at multiple places. Fixes #1100.
28 lines
451 B
Go
28 lines
451 B
Go
package main
|
|
|
|
import "strings"
|
|
|
|
func f(s string) string { return "hello " + s }
|
|
|
|
func g(s string) string { return "hi " + s }
|
|
|
|
var methods = map[string]func(string) string{
|
|
"f": f,
|
|
"h": strings.ToLower,
|
|
}
|
|
|
|
func main() {
|
|
methods["i"] = strings.ToUpper
|
|
methods["g"] = g
|
|
println(methods["f"]("test"))
|
|
println(methods["g"]("test"))
|
|
println(methods["i"]("test"))
|
|
println(methods["h"]("TEST"))
|
|
}
|
|
|
|
// Output:
|
|
// hello test
|
|
// hi test
|
|
// TEST
|
|
// test
|