Skip to content

Instantly share code, notes, and snippets.

@Raynos
Last active August 29, 2015 14:02
Show Gist options
  • Save Raynos/9a33bfff24d24ed45a4b to your computer and use it in GitHub Desktop.
Save Raynos/9a33bfff24d24ed45a4b to your computer and use it in GitHub Desktop.
interface Car {
run(fuel: string);
}
interface Human {
run(distance: number);
}
// Makes the specified object go
// run := (Car, string)
// run := (Human, number)
public void run(obj, v) {
if( typeof v === 'string' ) {
(<Car>obj).run(fuel);
} else {
(<Human>obj).run(dist);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment