带有示例的 Scala Float isValidShort() 方法
isValidShort()方法用于在指定数字为零或在 scala.Short MinValue 和 MaxValue 范围内时返回 true;否则返回假。
Method Definition: (Float_Number).isValidShort
Return Type: It returns true if the specified number is either zero or lies within the range of scala.Short MinValue and MaxValue; otherwise returns false.
示例 #1:
// Scala program of Float isValidShort()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isValidShort method
val result = (0).isValidShort
// Displays output
println(result)
}
}
输出:
true
示例 #2:
// Scala program of Float isValidShort()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isValidShort method
val result = (5.9).isValidShort
// Displays output
println(result)
}
}
输出:
false