From fbd4b60834f0c8d2c98a03166d78a68736526640 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Wed, 3 Feb 2016 12:48:08 +0100 Subject: [PATCH] Minor: allow double constants to be used to create Amounts, you can now write 35.99.DOLLARS to mean $35.99 --- src/main/kotlin/core/ContractsDSL.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/core/ContractsDSL.kt b/src/main/kotlin/core/ContractsDSL.kt index 48e66bc4f9..c16fbe4953 100644 --- a/src/main/kotlin/core/ContractsDSL.kt +++ b/src/main/kotlin/core/ContractsDSL.kt @@ -35,6 +35,8 @@ val Int.DOLLARS: Amount get() = Amount(this.toLong() * 100, USD) val Int.POUNDS: Amount get() = Amount(this.toLong() * 100, GBP) val Int.SWISS_FRANCS: Amount get() = Amount(this.toLong() * 100, CHF) +val Double.DOLLARS: Amount get() = Amount((this * 100).toLong(), USD) + //// Requirements ///////////////////////////////////////////////////////////////////////////////////////////////////// class Requirements { @@ -89,6 +91,8 @@ data class Amount(val pennies: Long, val currency: Currency) : Comparable