(Scala) Am I using Options correctly?
(Scala) Am I using Options correctly? I'm currently working on my functional programming - I am fairly new to it. Am i using Options correctly here? I feel pretty insecure on my skills currently. I want my code to be as safe as possible - Can any one point out what am I doing wrong here or is it not that bad? My code is pretty straight forward here: def main(args: Array[String]): Unit = { val file = "myFile.txt" val myGame = Game(file) //I have my game that returns an Option here if(myGame.isDefined) //Check if I indeed past a .txt file { val solutions = myGame.get.getAllSolutions() //This returns options as well if(solutions.isDefined) //Is it possible to solve the puzzle(crossword) { for(i <- solutions.get){ //print all solutions to the crossword i.solvedCrossword foreach println } } } } -Thanks!! ^^ Why does getAllSolutions return an option? Is there a semantic di...