I am writing a code to print all characters and its ascii value from 'a' to 'z'.
With the following code snippet I am able to do this.
var c = 'a' while(c < 'z'){ println(c +" = " + c.toInt) var p = c.toInt p += 1 c = p.toChar } But when I am doing following(like c)
var c = 'a' while(c < 'z'){ println(c +" = " + c.toInt) c += 1 // or c = c + 1.toChar } it is giving me following error
found : Int required: Char Is there any better way to increment character in scala.
Thanks,
Shantanu
('a' to 'z').foreach(println)for your basic task, which is printing ASCII values from a to z?.map(_.toInt)beforeforeachthen.