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

Can ifViewAttached return result of last statement in its scope? #331

Open
rishabh876 opened this issue Mar 25, 2019 · 2 comments
Open

Can ifViewAttached return result of last statement in its scope? #331

rishabh876 opened this issue Mar 25, 2019 · 2 comments

Comments

@rishabh876
Copy link

rishabh876 commented Mar 25, 2019

Hi, this is just a feature request that will make code a bit cleaner and easier to write.

let's say we have

ifViewAttached { 
    val message = it.getStringFromId(R.string.some_id)
    showError(message)
 } 

This will become

val message =  ifViewAttached { it.getStringFromId(R.string.some_id) }
showError(message)

here ifViewAttached returned the value returned by function getStringFromId.
This works very similar to let function in Kotlin.

@sockeqwe
Copy link
Owner

is showError() interacting with the view?

If yes, why would you move showError() outside of the ifViewAttached { ... } block?

@rishabh876
Copy link
Author

rishabh876 commented Mar 25, 2019

This is actually just a simplified logic to show how it can help. I don't use it this way but I prefer writing only view's function inside ifViewAttached and rest outside. Otherwise things look nested for no reason.

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

2 participants