Skip to content

Instantly share code, notes, and snippets.

@tangentlin
Created March 31, 2024 01:20
Show Gist options
  • Save tangentlin/cdb62b7c4c337ed517f85576096f3753 to your computer and use it in GitHub Desktop.
Save tangentlin/cdb62b7c4c337ed517f85576096f3753 to your computer and use it in GitHub Desktop.
Imperative programming example
function processPayment(amount: number, method: string) {
switch (method) {
case 'credit':
// Process credit card payment
break;
case 'paypal':
// Process PayPal payment
break;
case 'bank_transfer':
// Process bank transfer
break;
// More payment methods...
default:
throw new Error('Unsupported payment method');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment