https://kotlinlang.org logo
Title
p

Paul Woitaschek

12/21/2020, 11:18 PM
Thank you compose team! I didn't laugh that much while developing for a while now 😂 And yes, I just finished Queens Gambit on Netflix 🙈
:kotlin-intensifies: 1
👏🏼 9
🔥 5
i

ian.shaun.thomas

12/21/2020, 11:23 PM
ship it
🚢 2
🐿 2
b

Big Chungus

12/22/2020, 12:00 AM
Is it intentionally so buggy?
p

Paul Woitaschek

12/22/2020, 12:05 AM
Isn't this how chess is supposed to work?
😄 8
o

Ole K. Øverland (Norway)

12/22/2020, 7:48 AM
Chess 2.0
m

marstran

12/22/2020, 8:04 AM
Is this the off-by-1 opening?
p

Paul Woitaschek

12/22/2020, 8:05 AM
It's the cut-out-pieces-of-the-board-with-a-saw opening
😄 2
x

xetra11

12/22/2020, 8:52 AM
it should be called Chonk
@Paul Woitaschek also how dare you to do this in kotlin?
p

Paul Woitaschek

12/22/2020, 8:53 AM
What's wrong with that?
m

Michal Harakal

12/22/2020, 9:08 AM
removed?.let {
}
@xetra11?
🇳🇴 1
x

xetra11

12/22/2020, 9:15 AM
ye do the let stuff with fancy kotlin nullables
its magic @Paul Woitaschek please join the magical side
p

Paul Woitaschek

12/22/2020, 9:17 AM
Nah the code is fine like it is
👍 5
☝️ 1
Its easy to read and makes use of smart casts
1
👍 4
b

Big Chungus

12/22/2020, 9:18 AM
I'm with @Paul Woitaschek on this one. Let can be easily abused
x

xetra11

12/22/2020, 9:22 AM
@Big Chungus Do you have an example at hand?
b

Big Chungus

12/22/2020, 9:24 AM
Not at hand, but too many nested let push the code too far to the right and can make it hard to follow. All I'm saying is that java style null checks are nothing to be affraid of. While they are a bit more verbose, I feel they make the code easier to follow.
x

xetra11

12/22/2020, 9:26 AM
Hm wouldn't the amount of nested if (x != null) be the same as the ones of nested lets ?
It took me a while to "feel" let like I felt if (x != null) that I have to admit. But after I became warm with
?
and the whole things I really feel it's nicer. Just my opinion tho.
b

Big Chungus

12/22/2020, 9:30 AM
Yes, but you can do multiple null checks in java style check
x

xetra11

12/22/2020, 9:36 AM
Well ok that is possible but I don't design code like that - so I think we have different styles 😄 luckily there is something for everybody ;0
p

Paul Woitaschek

12/22/2020, 9:44 AM
I only use ?.let for scoping when the body of the function becomes so complex that the scoping is actually helpful. But in most cases that applies, I'd refactor the function into smaller functions before doing that. Regular if checks make use of smart casts and whats nice of these is that multiple smart casts work together.
☝️ 1
👍 1
This:
if (currency != null && rate != null) {
  result[currency] = rate
}
Is easier to understand than this:
currency?.let {
  rate?.let { rate ->
    result[it] = rate
  }
}
16
x

xetra11

12/22/2020, 2:47 PM
Well I have to admit that this is true. However as I mentioned I rarely come over code sections where I need to check two things for
null
since I strip them to be not null as early as possible. In my projects nullable data is mostly coming from perstistence or filesystem layers and I strip them to notnull as soon as I read/query the data. Afterwards I never have to care about null states again
g

gildor

12/24/2020, 1:03 PM
if null check is almost always better than using let for null check