Skip to content

add an Array() constructor example to the multi-dimensional-arrays theory - #353

Merged
fey merged 1 commit into
mainfrom
fix/313-array-constructor-example
Aug 5, 2026
Merged

add an Array() constructor example to the multi-dimensional-arrays theory#353
fey merged 1 commit into
mainfrom
fix/313-array-constructor-example

Conversation

@fey

@fey fey commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Closes #313

Решение учителя в уроке «Многомерные массивы» построено на Array<null>(size).fill(null).map(...), но в теории Array<Type> показан только как способ записи типа. Создание массива нужной длины через конструктор нигде не разобрано, поэтому вывести решение из материала невозможно.

Добавлен раздел «Создание массива нужной длины»: Array<T> как аннотация против Array<T>(n) как вызова конструктора, «дырявый» массив и почему map() пропускает пустые слоты, необходимость fill() перед map(), и в конце — двумерный случай, который и требуется в задании.

Все три вывода в комментариях проверены компиляцией и запуском (tsc + node):

[ <3 empty items> ]
[ 0, 0, 0 ]
[ [ null, null ], [ null, null ] ]

Array.from() и spread не упоминаются — вне скоупа issue. Задание и решение учителя не менялись. Заодно убран лишний пробел в конце строки в ru-файле (MD009).

🤖 Generated with Claude Code

…eory (#313)

The task is solved with Array<null>(size).fill(null).map(...), but the
theory showed Array<Type> only as a way to write a type — creating an
array of a given length was never covered, so the teacher's solution
looked like it came out of nowhere.

Added a section that separates Array<T> as an annotation from Array<T>(n)
as a constructor call, shows why fill() is needed before map() (map skips
empty slots), and ends with the two-dimensional case the task asks for.
All three outputs were verified by compiling and running the snippets.

Also stripped a pre-existing trailing space in the ru file (MD009).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@fey
fey force-pushed the fix/313-array-constructor-example branch from a21d295 to 8a99cc7 Compare August 5, 2026 15:25
@fey
fey merged commit 3bd37d5 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.

Добавить пример с созданием пустого массива через конструктор Array()

1 participant