jetbrains-academy / kotlin-onboarding-introduction

The introduction to the Kotlin Onboarding course
MIT License
9 stars 2 forks source link

Introduction/Hangman/Finish the game #164

Open edutools-service opened 11 months ago

edutools-service commented 11 months ago

Your tests check that my safeUserInput() function should return "Char". My idea was to return Char nullable because this way I could return null if the input was incorrect, check for null in the main playGame() cycle and interrupt the current iteration with continue, so that if the input is incorrect I could increase the number of attemtps. But I cannot do this (at least I couldn't find any neat way to do this) if safeUserInput() has to return Char and for that recursively run itself in case the input is incorrect. Although it wasn't discussed in the course if I have to treat incorrect inputs as additional attempts or not, I think it would be valid.