Skip to content

Instantly share code, notes, and snippets.

@diegogriep
Last active June 1, 2020 11:57
Show Gist options
  • Save diegogriep/6e3c23db9c0945869d513ad09d4c92aa to your computer and use it in GitHub Desktop.
Save diegogriep/6e3c23db9c0945869d513ad09d4c92aa to your computer and use it in GitHub Desktop.
function returnLastOne<T>(param: Array<T>): T {
return param.pop();
}
//ou
function returnLastOne<T>(param: T[]) { //implícito retorna tipo T
return param.pop();
}
let showLastOne = returnLastOne(['JavaScript', 'TypeScript', 'HTML']);
let showLastOneNumber = returnLastOne([1, 2, 3]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment