Skip to content

Write conditionals in Kotlin: Android Basics with Compose #210

@Althalus999

Description

@Althalus999

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

In which task and step of the codelab can this issue be found?
Write conditionals in Kotlin -> 4. Use if/else and when expressions

Describe the problem
The code is garbled. Copied it below.
fun main() {
val trafficLightColor = "Black"

val message = 
  if (trafficLightColor == "Red") "Stop"
  else if (trafficLightColor == "Yellow") "Slow"
  else if (trafficLightColor == "Green") "Go"
  else "Invalid traffic-light color"

println(message)

}

fun main() {
val trafficLightColor = "Amber"

val message = when(trafficLightColor) {
 >   "Red" - "Stop&quo>t;
    "Yellow&q>uot;, "Amber&qu>ot; - "Slow"
    "Green" - "Go"
    else - "Invalid traffic-light color"
}

}

fun main() {
val trafficLightColor = "Amber"

val message = when(trafficLightColor) {
 >   "Red" - "Stop&quo>t;
    "Yellow&q>uot;, "Amber&qu>ot; - "Slow"
    "Green" - "Go"
    else - "Invalid traffic-light color"
}
println(message)

}

in short, double quotes in some instances have been converted to &qu>to

Steps to reproduce?

  1. Go to...
    the url I posted in the first step.
  2. Click on...
    nothing, just look at the code
  3. See error...Versions
    Android Studio version:
    API version of the emulator:

Additional information
Include screenshots if they would be useful in clarifying the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions