The to(end: Char, step: Char) method is utilized to return a range from the stated character to the ‘end’, which is given in the arguments list and some “step” is also specified in the arguments list.
Method Definition: def to(end: Char, step: Char): Inclusive[Char]
Return Type: It returns the range.
Example: 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) } } |
chevron_right
filter_none
Output:
NumericRange(A, C, E, G)
Example: 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) } } |
chevron_right
filter_none
Output:
NumericRange(0, 3, 6, 9)
Recommended Posts:
- Scala Tutorial – Learn Scala with Step By Step Guide
- Scala Int to(end: int, step: int) method with example
- Scala Float to(end: Float, step: Float) method with example
- Scala Int until(end: Int, step: Int) method with example
- Scala Float until(end: Float, step: Float) method with example
- Scala Char |(x: Char) method with example
- Scala Char ^(x: Char) method with example
- Scala Char >=(x: Char) method with example
- Scala Char >(x: Char) method with example
- Scala Char ==(x: Char) method with example
- Scala Char <=(x: Char) method with example
- Scala Char !=(x: Char) method with example
- Scala Char %(x: Char) method with example
- Scala Char &(x: Char) method with example
- Scala Char *(x: Char) method with example
- Scala Char <(x: Char) method with example
- Scala Char /(x: Char) method with example
- Scala Char -(x: Char) method with example
- Scala Char +(x: Char) method with example
- Scala Char to(end: Char) method with example
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

