google-developer-training / basic-android-kotlin-compose-birthday-card-app

Apache License 2.0
125 stars 95 forks source link

Practice Problems: Kotlin Basics #816

Open briezee opened 3 months ago

briezee commented 3 months ago

URL of codelab https://developer.android.com/codelabs/basic-android-kotlin-compose-intro-kotlin-practice-problems?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-1-pathway-1%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-intro-kotlin-practice-problems#7

In which task and step of the codelab can this issue be found? Step One

Describe the problem println(displayAlertMessage(operatingSystem, emailId)) println(displayAlertMessage(operatingSystem, emailId))

Not so much as a bug as a suggestion: "display" is a verb and in console programming means the same thing as print. As a programmer, my first thought on this was to remove the println and just call displayAlertMessage. In other languages and conventions, display isn't something that has a return value of other than success or failure.

println(generateAlertMessage(...)) would get the result that you are striving for, as it would prompt the user to use a return statement.

I may have missed, but I did not see in the unit that println() will print the return type of a function if it doesn't provide a return type. I think this could be confusing to newer programmers when they get output like:

There's been a new sign-in ... Kotlin.Unit

They may not know where Kotlin.Unit comes from.