Created
August 20, 2019 04:11
-
-
Save bcherny/3e73b5c8da3c5a85ed1448c4a33222b8 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
/////////////// 1ST CODE SAMPLE (PAGE 140) /////////////// | |
type Unit = 'EUR' | 'GBP' | 'JPY' | 'USD' | |
type Currency = { | |
unit: Unit | |
value: number | |
} | |
let Currency = { | |
from(value: number, unit: Unit): Currency { | |
return { | |
unit: unit, | |
value | |
} | |
} | |
} | |
/////////////// 2ND CODE SAMPLE (PAGE 140) /////////////// | |
import {Currency} from './Currency' | |
let amountDue: Currency = { | |
unit: 'JPY', | |
value: 83733.10 | |
} | |
let otherAmountDue = Currency.from(330, 'EUR') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment