英文:
How can I define a function type adapted to any function in golang
问题
我只想定义一个能匹配所有函数的函数类型,我尝试了这样写:
type funcType func(...interface{}) ...interface{}
但是失败了
我该怎么做?
英文:
I just want to define a function type which will match all functions and I have tried this:
type funcType func(...interface{}) ...interface{}
but failed
How can I do this?
答案1
得分: 5
没有与任何函数兼容的函数类型。
你能做的最好的办法是使用interface{}
,它可以接受任何值,包括函数。
英文:
There is no function type that's compatible with any function.
The best you can do is interface{}
to which any value is assignable to, including functions.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论