jetbrains-academy / kotlin-onboarding-introduction

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

description says variable yet unit test expects val Introduction/Warm up/Types of variables #157

Closed edutools-service closed 11 months ago

edutools-service commented 1 year ago

the description is as follow "Description: Add variables of different types to customize the game and display the game information in the console:

Int variable wordLength to define the length of the word Int variable maxAttemptsCount to define the max number of user attempts String variable secretExample to define an example of the hidden word (to explain it to the user)" but i can see the solution failing in unit test with this error message "java.lang.IllegalStateException: The code should contains a definition of the wordLength variable! Please add or code in your solution.Please be careful with styles - check the spaces around =. at util.VariableKt.isVariableExist(Variable.kt:25)" java.lang.IllegalStateException: The code should contains a definition of the wordLength variable! Please add or code in your solution.Please be careful with styles - check the spaces around =. at util.VariableKt.isVariableExist(Variable.kt:25)

DaniilBogdanovJB commented 1 year ago

Hello,

In this case, using val (immutable) variables is expected since variables are not meant to be modified in the process.

In this exercise, the variables provide stored information in the output text. If it would require performing any operations with them (reassignments), using var (mutable) variables will be suitable. IDE additionally highlights variable definitions if you try to use mutable variables.

The usage of mutable variables is described in the "Loops" lesson.