Skip to content

Kotlin-7 #29

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

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Conversation

crayfish1975
Copy link

@crayfish1975 crayfish1975 commented Sep 15, 2024

Что я вообще наделал? Я не понял как я сделал это дз. Если это возможно, можно пожалуйста объяснить почему при добавлении приставки "private" к переменной errors во втором задании, исчезает ошибка (Type parameter E is declared as 'in' but occurs in 'invariant' position in type MutableList<Pair<LocalDateTime, E>>)?
И зачем вообще в определении переменной (val errors = mutableListOf<Pair<LocalDateTime, E>>()) нужен "E", если его можно заменить на "Throwable", и все будет работать, и даже без "private"?

@@ -30,6 +30,8 @@ class ErrorLogger<E : Throwable> {
println("Error at $date: ${error.message}")
}
}

fun dump(): List<Pair<LocalDateTime, Throwable>> = errors
Copy link
Collaborator

Choose a reason for hiding this comment

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

@crayfish1975 , не совсем верно. Должно быть:

fun dump(): List<Pair<LocalDateTime, E>>

@crayfish1975
Copy link
Author

crayfish1975 commented Sep 16, 2024 via email

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