Skip to content

clarify the filter() return type in the generic-functions exercise - #351

Merged
fey merged 1 commit into
mainfrom
fix/269-generic-filter-return-type
Aug 5, 2026
Merged

clarify the filter() return type in the generic-functions exercise#351
fey merged 1 commit into
mainfrom
fix/269-generic-filter-return-type

Conversation

@fey

@fey fey commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Closes #269

Задание урока «Дженерики (Функции)» говорило, что push() и filter() «совпадают по сигнатуре с методами Array». Но filter() обязан возвращать MyArray<T>, а не T[]: иначе newColl.items из примера в этом же задании не типизируется. Из-за этого студент решил, что решение учителя ошибочно.

Теперь текст разделяет, что совпадает (параметры колбэка), а что отличается (тип возврата). index.ts и test.ts не менялись.

🤖 Generated with Claude Code

)

The task said push() and filter() match the signature of Array methods,
while filter() has to return MyArray<T> rather than T[] — otherwise the
newColl.items line from the very same example does not type-check.

Now the text spells out what matches (the callback parameters) and what
differs (the return type), so a student arrives at the same signature as
the teacher's solution. The type and the test are unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@fey
fey force-pushed the fix/269-generic-filter-return-type branch from 223ccda to 3462c97 Compare August 5, 2026 15:25
@fey
fey merged commit 7a1a1af into main Aug 5, 2026
2 checks passed
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.

Тот ли тип должен возвращаться из filter()? Урок 46, Дженерики (функции)

1 participant