Okay so I'm trying to make a conway's game of life in swift. I am trying to create a UI that allows the user to input coordinates that start off alive. However when they are done, I am trying to get it so they click enter with nothing there and it moves. I put a "yes!" to represent where I'm trying to get the code, but I just can't get it to "yes!", when i enter it in as nothing, I get an index out of bounds error.
func splitStrPar(_ expression: String) -> [String] {
return expression.split{$0 == " "}.map{ String($0) }
}
func getCommand() -> [String] {
return splitStrPar(readLine()!)
}
func setup() {
print("Enter x y coordinates of living cells, blank line when done")
print("Coor" , terminator : ":")
var command = getCommand()
print(command[0])
while(command[0] != "") {
print("Coor" , terminator : ":")
command = getCommand()
}
print("yes!")
}