why cannot use (type func(string)) as type func(interface{}) in assignment

前端 未结 1 1450
误落风尘
误落风尘 2021-01-29 15:02

Please first have a look at the code below.

package main

import \"fmt\"

type InterfaceFunc func(interface{})
type StringFunc func(string)

func stringFunc(s st         


        
相关标签:
1条回答
  • 2021-01-29 16:05

    You can not do s = i or i = s, and the reason is both functions are of different type (different signatures), you can not just assign one type with another in golang.

    Also type InterfaceFunc func(interface{}) type StringFunc func(string) are sitting there doing nothing.

    0 讨论(0)
提交回复
热议问题