Skip to content

Commit 437e083

Browse files
committed
Uses Integer values when creating BigDecimal values to avoid the decimal point when calling toString
1 parent c6cd0a9 commit 437e083

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/scala/stdlib/Implicits.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ object Implicits extends FlatSpec with Matchers with org.scalaexercises.definiti
105105
def asDefaultImplicits(res0: BigDecimal) {
106106
def howMuchCanIMake_?(hours: Int)(implicit dollarsPerHour: BigDecimal) = dollarsPerHour * hours
107107

108-
implicit val hourlyRate = BigDecimal(34.00)
108+
implicit val hourlyRate = BigDecimal(34)
109109

110110
howMuchCanIMake_?(30) should be(res0)
111111
}
@@ -116,7 +116,7 @@ object Implicits extends FlatSpec with Matchers with org.scalaexercises.definiti
116116
def howMuchCanIMake_?(hours: Int)(implicit amount: BigDecimal, currencyName: String) =
117117
(amount * hours).toString() + " " + currencyName
118118

119-
implicit val hourlyRate = BigDecimal(34.00)
119+
implicit val hourlyRate = BigDecimal(34)
120120
implicit val currencyName = "Dollars"
121121

122122
howMuchCanIMake_?(30) should be(res0)

src/test/scala/stdlib/ImplicitsSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ImplicitsSpec extends Spec with Checkers {
3535
}
3636

3737
def `implicits for default parameters` = {
38-
val fstAnswer: BigDecimal = 1020.0f
38+
val fstAnswer: BigDecimal = 1020
3939

4040
check(
4141
Test.testSuccess(
@@ -49,7 +49,7 @@ class ImplicitsSpec extends Spec with Checkers {
4949
check(
5050
Test.testSuccess(
5151
Implicits.listOfImplicitsImplicits _,
52-
"1020.0 Dollars" :: HNil
52+
"1020 Dollars" :: HNil
5353
)
5454
)
5555
}

0 commit comments

Comments
 (0)