Reputation: 3560
I have to define a method, that by restriction can only be called with one parameter (a Subscriber). I need to pass several values, so I group them in a tuple.
In the subscriber, I would like to access each variable of the tuple as its own name. So I am looking for syntax like
([name:string, age:number, salary: number]) => {
console.log("our name is " + name);
}
Does typescript support this?
Upvotes: 1
Views: 49
Reputation: 250156
You can use array de-structuring syntax:
([name, age, salary]: [string, number, number]) => {
console.log("our name is " + name);
}
Upvotes: 1