I have a function drawSnake
which is called as follows:
drawSnake(
[
[0, 0],
[0, 1],
[0, 2],
[0, 3],
[0, 4],
]
);
How can I type the input for this function?
I have tried something like Array<Array<[number, number]>>
but it doesn't seem to be right.
function drawSnake(snake: ???) {
...
}
as stated on comments (@VLAZ). You can do it like this
function drawSnake(snake: Array<[number, number]>) {
...
}
Thanks to @VLAZ and @thedude in the comments above, this can be solved in 2 ways:
#1:
Array<[number, number]>
#2:
[number, number][]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.