to(end:Char,step:Char)方法用於返回從指定字符到“ end”的範圍,該範圍在參數列表中給出,並且在參數列表中也指定了一些“step”。
函數定義: def to(end:Char, step:Char):Inclusive[Char]
返回類型: It returns the range.
示例: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', 2)
// Displays output
println(result)
}
}
輸出:
NumericRange(A, C, E, 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', 3)
// Displays output
println(result)
}
}
輸出:
NumericRange(0, 3, 6, 9)
相關用法
注:本文由純淨天空篩選整理自nidhi1352singh大神的英文原創作品 Scala Char to(end: Char, step: Char) method with example。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。