Scala Char to(end:Char)示例方法

Scala Char to(end:Char)示例方法

to(end:Char)方法用于从所述字符返回范围到参数列表中给出的“end”,但此处未在参数列表中指定“step”。

方法定义:def to(end:Char):Inclusive [Char]

返回类型:它返回范围。

例:1#

// Scala program of to()
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
        // Applying to() method 
        val result = 'A'.to('G')
          
        // Displays output
        println(result)
      
    }
} 
NumericRange(A,B,C,D,E,F,G)

例:2#

// Scala program of to()
// method
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
        // Applying to() method
        val result =('0').to('9')
          
        // Displays output
        println(result)
      
    }
} 
NumericRange(0,1,2,3,4,5,6,7,8,9)

更多Scala相关文章,请阅读:Scala 教程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程