我正在尝试创建一个不和谐的机器人来检查消息是否包含存储在数组中的字符串。我尝试使用 for 循环,但它没有工作,因为它永远持续下去,我想减少代码行,有什么办法吗?
switch {
case strings.Contains(mContent, characterss[0]):
currentCharacter = characterss[0]
currentDescription = descriptions[0]
currentImage = images[0]
isCorrect = true
case strings.Contains(mContent, characterss[1]):
currentCharacter = characterss[1]
currentDescription = descriptions[1]
currentImage = images[1]
isCorrect = true
case strings.Contains(mContent, characterss[2]):
currentCharacter = characterss[2]
currentDescription = descriptions[2]
currentImage = images[2]
isCorrect = true
case strings.Contains(mContent, characterss[3]):
currentCharacter = characterss[3]
currentDescription = descriptions[3]
currentImage = images[3]
isCorrect = true
case strings.Contains(mContent, characterss[4]):
currentCharacter = characterss[4]
currentDescription = descriptions[4]
currentImage = images[4]
isCorrect = true
case strings.Contains(mContent, characterss[5]):
currentCharacter = characterss[5]
currentDescription = descriptions[5]
currentImage = images[5]
isCorrect = true
case strings.Contains(mContent, characterss[6]):
currentCharacter = characterss[6]
currentDescription = descriptions[6]
currentImage = images[6]
isCorrect = true
}
HUH函数
相关分类