From 406a66fc68f3dbce2d341a3f792af7ce0d40057d Mon Sep 17 00:00:00 2001 From: Dmitry Kandalov Date: Sun, 22 Oct 2023 19:22:42 +0100 Subject: [PATCH] formatting WeatherExample --- .../forkhandles/result4k/WeatherExample.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/result4k/core/src/test/kotlin/dev/forkhandles/result4k/WeatherExample.kt b/result4k/core/src/test/kotlin/dev/forkhandles/result4k/WeatherExample.kt index 59a5ba3..a63f7a6 100644 --- a/result4k/core/src/test/kotlin/dev/forkhandles/result4k/WeatherExample.kt +++ b/result4k/core/src/test/kotlin/dev/forkhandles/result4k/WeatherExample.kt @@ -9,19 +9,19 @@ data class WeatherError(val code: Int, val message: String) private val cold = 283.15.toBigDecimal() private val hot = 298.15.toBigDecimal() -fun getWeather(location: Int): Result = when(location) { - in 1..100 -> Success(Weather(kelvin = BigDecimal("295.15"), pascals = 101_390)) - else -> Failure(WeatherError(code = 404, message = "unsupported location")) -} +fun getWeather(location: Int): Result = + when (location) { + in 1..100 -> Success(Weather(kelvin = BigDecimal("295.15"), pascals = 101_390)) + else -> Failure(WeatherError(code = 404, message = "unsupported location")) + } -fun Weather.toConditions(): Result { - return when { - kelvin < BigDecimal.ZERO -> Failure(WeatherError(400, "impossible!")) - kelvin < cold -> Success(Conditions("cold :(")) - kelvin > hot -> Success(Conditions("HOT! X(")) - else -> Success(Conditions("Nice :)")) - } -} +fun Weather.toConditions(): Result = + when { + kelvin < BigDecimal.ZERO -> Failure(WeatherError(400, "impossible!")) + kelvin < cold -> Success(Conditions("cold :(")) + kelvin > hot -> Success(Conditions("HOT! X(")) + else -> Success(Conditions("Nice :)")) + } /** * Get the current weather, interpret the conditions, and print them