Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.

Conversation

@mahmoud-drwsh
Copy link

No description provided.

override fun getItemCount(): Int {
return list.size
}
override fun getItemCount(): Int = list.size

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's possible to improve even more, what do you think about that?

Suggested change
override fun getItemCount(): Int = list.size
override fun getItemCount() = list.size

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pierre I think the way it as originally was better for initial understanding. Then as you rightly pointed out the condensed refactored version is how you would solve on the job. The original in my opinion helps with basic beginner understanding ie. It highlights getItemCount is a function with return type Int and the return FROM that function is the list size. With out knowing this, its possible to interpret the condensed version as a variable assignment. Then what getItemCount does with it? and why not as a parameter to the variable etc. So a whole rabbit hole of questions which pop up during the learning journey.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants