Quicker if-statement: if `variable` is “value” or “value”

前端 未结 7 2111
感情败类
感情败类 2020-12-18 15:44

How can you compare against multiple possibilities in one argument?

Example:

if ((integer == 2) || (integer == 5))

if ((string == \"hello\") || (str         


        
7条回答
  •  感情败类
    2020-12-18 16:15

    Create a variadic function or one that receives an array of strings for the comparison.

提交回复
热议问题