Scala - How to read more than one integer in one line in and get them in one variable each? Code Example

The code for How to read more than one integer in one line in and get them in one variable each?

// You could use the following code which will read a line 
// and use the first 3 whitespace separated tokens as the input.
// (Expects e.g. "1 2 3" as the input on one line)

val Array(m,n,d) = readLine.split(" ").map(_.toInt)
Code by IncludeHelp, on August 8, 2022 02:46
Reference: stackoverflow.com

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.