I can't decide which is the best option for adding...
# random
v
I can't decide which is the best option for adding 3 numbers?
K 4
3️⃣ 1
JS 2
😂 1
i
The best - do not reinvent the wheel
r
Copy code
infix fun Int.div(n :Int): Int = this + n
And let the anarchy begin 🦜
1
🎉 2
🦜 2
r
I assume ya come from Haskell or similar environment? 😛
d
Please let this be some kind of joke
2
😂 2
v
Haskell doesn't support IntelliJ IDEA well 🤫
b
I was thinking about this last night. Currying. It's necessary in functional programming, because it's the only way to have multiple arguments. But other than contrived examples, I've never seen a realistic, plain, valuable approach that benefitted from currying when it wasn't required.
👍 1
v
@Byron Katz Where partial application is needed. I liked this example.
b
I always found it easier to follow a plain procedural approach
v
I think this is a matter of taste. 🙂
r
imho, currying is useless, or near useless in Kotlin you got 2 great alternatives: a) lambdas, which you can easily use for making new functions b) if you need to do a lot of currying in same way, a class with
invoke
will be indistinguishable by usage, but it's definition will definitely be clearer on what it's doing you shown b) there, even if not with invoke and by lambdas you can simply do:
Copy code
fun countTax(price: Double, taxRate: Double): Double = price * taxRate + price
val countMyCountryTax = { price: Double -> countTax(price, 0.2) }

countMyCountryTax(100.0)
which makes it clear what exactly
countMyCountryTax
function does by looking at it and can be used as value you could even just define it by
fun
and it would be clear
v
It's just for fun. Obviously. If I used currying at work, I would not be understood and what this function does too.
Quite realistic. Seem to be. 🙂
m
The best curry is the vegetable biriyani one 😜