How to get the last element from array if present. In below code num contains array of elements
var line_ = ln.trim
if(!line_.isEmpty) {
var num = line_.split(" ");
}
Just use last:
var num = line_.split(" ").last;
val num = ln.trim.split(" ").last. Do you really like to read few lines instead of one?