Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text composables: Android Basics with Compose #984

Open
etlweather opened this issue Jan 4, 2025 · 0 comments
Open

Text composables: Android Basics with Compose #984

etlweather opened this issue Jan 4, 2025 · 0 comments

Comments

@etlweather
Copy link

URL of codelab

https://developer.android.com/codelabs/basic-android-kotlin-compose-classes-and-objects?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-classes-and-objects#5

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

  1. Define a constructor

Describe the problem

The text reads:

The syntax to define a primary constructor starts with the class name followed by the constructor keyword and a set of parentheses.

This is not consistent with the code example just below and is frankly not true. Perhaps it can be written like this but it is not necessary and all the examples show it without the word "constructor".

Here is the code example below which contradicts the text:

class SmartDevice(val name: String, val category: String) {
    var deviceStatus = "online"

    constructor(name: String, category: String, statusCode: Int) : this(name, category) {
        deviceStatus = when (statusCode) {
            0 -> "offline"
            1 -> "online"
            else -> "unknown"
        }
    }
    ...
}

Steps to reproduce?
N/A

Versions
Android Studio version:
API version of the emulator:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant