Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
How to type a function that takes an array of arrays as input

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: ???) {
    ...
  }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Thanks to @VLAZ and @thedude in the comments above, this can be solved in 2 ways:

#1:

   Array<[number, number]>

#2:

   [number, number][]
about 4 years ago · Juan Pablo Isaza Report

0

as stated on comments (@VLAZ). You can do it like this

function drawSnake(snake: Array<[number, number]>) {
    ...
  }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!