Skip to content
This repository has been archived by the owner on Nov 14, 2018. It is now read-only.

For consistency, withXXX methods should return the last value of the passed lambda #431

Open
LouisCAD opened this issue Mar 13, 2018 · 2 comments

Comments

@LouisCAD
Copy link
Contributor

with from Kotlin stdlib returns value of its last expression, if any, and in other places of the Kotlin world, withXXX methods do the same to follow this convention, yet in androidx they return Unit as seen there: https://android.github.io/android-ktx/core-ktx/androidx.graphics/android.graphics.-canvas/index.html

This should be fixed for the sake of consistency.

@JakeWharton
Copy link
Contributor

I'd be open to returning the Canvas. I don't see much reason to return from the lambda though.

@LouisCAD
Copy link
Contributor Author

LouisCAD commented Mar 13, 2018

If the methods don't return the last expression, they shouldn't be named withXXX IMHO.

doWithXXX or applyWithXXX would be less confusing in regards to the naming convention. The do variant may return Unit and the apply variant, the Canvas, following what apply from Kotlin stdlib does.

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

No branches or pull requests

2 participants