``` fun Foo(x: Float?): Boolean { var result =...
# getting-started
l
Copy code
fun Foo(x: Float?): Boolean {
    var result = false
    if (x != null) {
        result = x > 1f
    }
    return result
}
can this be simplified? maybe using elvis operator somehow?
s
Copy code
return x?.let { it > 1f } ?: false
K 1
r
Copy code
fun Foo(x: Float?) = x != null && x > 1f
👍 3
1
b
fun Foo(x: Float?) = (x ?: 0f) > 1f
🥇 2
t
@Ruckus Is the most readable imho
👍 1
m
So would be this? fun newFoo(x:Float?):Boolean {return x?.let{ it>1f }?:false}