作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道我们可以编写带有忽略大小写的if, else if, else if
。
if (someString.equals("otherString", ignoreCase = true)) {
}
我对此很好奇,如何在不考虑大小写的情况下编写when(在Java中是一个开关)条件。
最佳答案
有两种选择:
when (someString.toLowerCase()) {
"otherString1".toLowerCase() -> { /*...*/ }
"otherString2".toLowerCase() -> { /*...*/ }
}
equals
方法: when {
someString.equals("otherString1", ignoreCase = true) -> { /*...*/ }
someString.equals("otherString2", ignoreCase = true) -> { /*...*/ }
}
关于kotlin - 当条件与忽略案件在 Kotlin ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63377560/
具有以下值的输入行(例如,仅显示 2 行,但可能有更多行;当然值可能不同) entry_id | transaction_partner_name | registration_numb
我是一名优秀的程序员,十分优秀!