Damian
12/02/2019, 6:21 PMpackage aquarium
class Aquarium (var length: Int, var width: Int, var height: Int) {
var volume: Int
get() = width * height * length / 1000
set(value) = {height = (value * 1000) / (width * length)}
This is the warning I'm getting from Intellij for the set(value):
Type mismatch: inferred type is () -> Unit but Unit was expected
I don't understand what is this supposed to signify?Ruckus
12/02/2019, 6:32 PM= after set(value)Zachary Grafton
12/02/2019, 6:38 PM= in set(value) = { ... } otherwise you are indicating that the setter is returning a lambda. The Type mismatch: inferred type is () -> Unit but Unit was expected is indicating that by stating that the compiler is expecting a Unit type but is finding () -> Unit as type. Remember that a { starts a block and that } ends a block, and assigning a block is creating a lambda. I make that mistake a lot too, even after working with kotlin for years. 😅