带有示例的 Scala Char unary_+() 方法
unary_+()方法用于将指定的字符转换为它的值,无需任何修改。
Method Definition: def unary_+: Int
Return Type: It returns 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