ragunathjawahar
04/15/2019, 4:12 PMShow
Typeclass? Is this correct?
data class Temperature(
val value: Double
)
val celsiusShow = Show<Temperature> {
val celsius = value - 273.15
return@Show celsius.to2DecimalPlaces()
}
val fahrenheitShow = Show<Temperature> {
val fahrenheit = (value - 273.15) * 9.0 / 5.0 + 32
return@Show fahrenheit.to2DecimalPlaces()
}
// usage
temperatureTextView.text = celsiusShow.run { zeroKelvin.show() }