带有示例的 Scala Char toDouble() 方法
toDouble()方法用于将指定字符转换为 Double 或 Double 类型的 ASCII 值。
Method Definition: def toDouble: Double
Return Type: It returns Double or ASCII value of the corresponding letter of type Double.
示例:1#
// Scala program of toDouble()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toDouble method to uni-code representation of character
val result = '\u0051'.toDouble
// Displays output
println(result)
}
}
输出:
81.0
这里,'\u0051' 是 Q 的 uni-code 表示。
示例:2#
// Scala program of toDouble()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toDouble method
val result = '\n'.toDouble
// Displays output
println(result)
}
}
输出:
10.0