Scala Char ==(x: Int) 方法及示例
==(x: Int)方法用于查找指定的字符值是否等于“x”,’x’的类型必须为Int。
方法定义:def ==(x: Int): Boolean
返回类型:如果指定的字符值等于“x”,则返回true;否则返回false。
例子:1#
// Scala program of ==(x: Int)
// method
// Creating object
object GfG {
// Main method
def main(args:Array[String]) {
// Applying ==(x: Int) method
val result = 'D'.==(100)
// Displays output
println(result)
}
}
false
例子:2#
// Scala program of ==(x: Int)
// method
// Creating object
object GfG {
// Main method
def main(args:Array[String]) {
// Applying ==(x: Int) method
val result = 'A'.==(65)
// Displays output
println(result)
}
}
true
更多Scala相关文章,请阅读:Scala 教程
极客教程