📜  Scala short <(x: Char): 布尔值

📅  最后修改于: 2022-05-13 01:54:28.810000             🧑  作者: Mango

Scala short <(x: Char): 布尔值

简而言之,一个 16 位有符号整数(相当于 Java 的 short 原始类型)是 scala.AnyVal 的子类型。如果该值小于 x,则使用 <(x: Char) 方法返回 true,否则返回 false。

示例 #1:

Scala
// Scala program of Short <(x: Char)
// method
 
// Creating object
object GfG
{
 
    // Main method
    def main(args:Array[String])
    {
     
        // Applying Short <(x: Char) function
        val result = (998.toShort).<('G':Char)
         
        // Displays output
        println(result)
     
    }
}


Scala
// Scala program of Short <(x: Char)
// method
 
// Creating object
object GfG
{
 
    // Main method
    def main(args:Array[String])
    {
     
        // Applying Short <(x: Char) function
        val result = (55.toShort).<('V':Char)
         
        // Displays output
        println(result)
     
    }
}


输出:

false

示例 #2:

斯卡拉

// Scala program of Short <(x: Char)
// method
 
// Creating object
object GfG
{
 
    // Main method
    def main(args:Array[String])
    {
     
        // Applying Short <(x: Char) function
        val result = (55.toShort).<('V':Char)
         
        // Displays output
        println(result)
     
    }
}

输出:

true