Created
January 4, 2026 17:57
-
-
Save davidystephenson/d1df950b9205b60b8e19019d67c9daef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Van <Cargo> { | |
| destination: string | |
| cargo: Cargo | |
| } | |
| const bakeryVan = { | |
| destination: 'bakery', | |
| cargo: 5 | |
| } | |
| const schoolVan = { | |
| destination: 'school', | |
| cargo: ['Dorothy', 'Zelda', 'Tallulah'] | |
| } | |
| function deliver <Cargo> (van: Van<Cargo>) { | |
| console.log('Delivery arrived at', van.destination) | |
| return van.cargo | |
| } | |
| function receiveBags (bags: number) { | |
| console.log(bags, 'bags received') | |
| } | |
| function receivePassengers (passengers: string[]) { | |
| const joined = passengers.join(', ') | |
| console.log('Passengers received:', joined) | |
| } | |
| const bakeryDelivery = deliver(bakeryVan) | |
| receiveBags(bakeryDelivery) | |
| const schoolDelivery = deliver(schoolVan) | |
| receivePassengers(schoolDelivery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment