Scala Char unary_-() 方法与示例
unary_-()方法用于给出所述字符的否定值。
Method Definition: def unary_-: Int
Return Type: It returns negative Integer value of the stated character.
示例:1#
// Scala program of unary_-()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying unary_- method
val result = '9'.unary_-
// Displays output
println(result)
}
}
输出:
-57
示例:2#
// Scala program of unary_-()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying unary_- method
val result = 'A'.unary_-
// Displays output
println(result)
}
}
输出:
-65