Skip to content

Консольное приложение#1

Open
NS-ClapZz wants to merge 1 commit intomainfrom
dev
Open

Консольное приложение#1
NS-ClapZz wants to merge 1 commit intomainfrom
dev

Conversation

@NS-ClapZz
Copy link
Owner

No description provided.

Choose a reason for hiding this comment

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

Всю папку .idea лучше сразу добавлять в gitignore - в ней хранятся локальные настройки разработчика, специфичные для проекта. После добавления важно не забыть удалить папку с репозитория

}

fun readString(prompt: String): String {
while (true) {

Choose a reason for hiding this comment

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

Не рекомендую писать бесконечные циклы через while (true) - лучше всегда явно прописывать условие выхода из цикла, чтобы уменьшить вероятность ошибиться и повысить читабельность кода

@@ -0,0 +1,40 @@
class Menu<T>(
private val title: String,
private val items: MutableList<T>,

Choose a reason for hiding this comment

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

Лучше сюда просто List передать, а не MutableList, т.к. внутри этого класса он не изменяется


data class Archive(
val name: String,
val notes: MutableList<Note> = mutableListOf()

Choose a reason for hiding this comment

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

В data классах не рекомендуется хранить мьютабельные данные (в данном случае MutableList), т.к. в многопоточных средах могут возникнуть проблемы с такими объектами, а именно с доступом к чтению и записи изменяемых полей. У data классов автоматически генерируется функция copy, которую можно использовать для изменения полей объекта с помощью его копирования

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