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

Practice problems Unit 2 Pathway 1: Android Basics with Compose #162

Open
ylcnymn opened this issue Dec 1, 2024 · 0 comments
Open

Practice problems Unit 2 Pathway 1: Android Basics with Compose #162

ylcnymn opened this issue Dec 1, 2024 · 0 comments

Comments

@ylcnymn
Copy link

ylcnymn commented Dec 1, 2024

A ---
name: Practice problems unit 2 pathway 1 issue template
about: Issue template for Unit 1 | Pathway 1 | Practice Problems
title: 'Practice problems Unit 2 Pathway 1: Android Basics with Compose'
labels: ''
assignees: ''


URL of codelab

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

Describe the problem

Additional information
Solution suggestions

fun auctionPrice(bid: Bid?, minimumPrice: Int): Int {
    return if (bid != null) {
        if (bid.amount >= minimumPrice) bid.amount else minimumPrice
    } else {
        minimumPrice
    }
}

or

fun auctionPrice(bid: Bid?, minimumPrice: Int): Int {
    return when {
        bid == null -> minimumPrice
        bid.amount >= minimumPrice -> bid.amount
        else -> minimumPrice
    }
}

or

fun auctionPrice(bid: Bid?, minimumPrice: Int): Int {
    return bid?.amount?.coerceAtLeast(minimumPrice) ?: minimumPrice
}

or

fun auctionPrice(bid: Bid?, minimumPrice: Int): Int {
    return bid?.let {
        it.amount.coerceAtLeast(minimumPrice)
    } ?: minimumPrice
}
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