我在 Go 中使用类型开关,例如以下一个:
switch question.(type) {
case interfaces.ComputedQuestion:
handleComputedQuestion(question.(interfaces.ComputedQuestion), symbols)
case interfaces.InputQuestion:
handleInputQuestion(question.(interfaces.InputQuestion), symbols)
}
有没有办法防止我必须在案例中声明问题类型,然后才能将其传递给另一个函数?
慕标5832272
相关分类