Skip to content

Conversation

satesalovskiy
Copy link

No description provided.

Comment on lines +27 to +31
name = getString(R.string.anon)

savedInstanceState?.getString(NAME_KEY)?.let {
name = it
}

Choose a reason for hiding this comment

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

Наверное не имеет смысла предварительно получать R.string.anon
можно записать это более лаконично, используя оператор Элвис:
name = savedInstanceState?.getString(NAME_KEY) ?: getString(R.string.anon)

data.getStringExtra((NewSecondActivity.NAME_KEY))?.let{
name = it
}
}

Choose a reason for hiding this comment

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

можно упростить условие и убрать из него data != null
вместо этого воспользуемся безопасным вызовом: ?.
data?.getStringExtra(NewSecondActivity.NAME_KEY)?.let{ name = it }
и лишние двойные скобки



companion object {
const val NAME_KEY = "com.example.kotlinhomework.MainActivity.NAME_KEY"

Choose a reason for hiding this comment

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

потерялся private

}

override fun afterTextChanged(s: Editable?) {
s?.let {

Choose a reason for hiding this comment

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

или можно так:
if (s.isNullOrEmpty().not()) button.isEnabled = true

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

Successfully merging this pull request may close these issues.

2 participants