Thank you compose team! I didn't laugh that much w...
# compose-desktop
p
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 🙈
K 1
🔥 5
👏🏼 9
i
ship it
🚢 2
🐿️ 2
b
Is it intentionally so buggy?
p
Isn't this how chess is supposed to work?
😄 8
o
Chess 2.0
m
Is this the off-by-1 opening?
p
It's the cut-out-pieces-of-the-board-with-a-saw opening
😄 2
x
it should be called Chonk
@Paul Woitaschek also how dare you to do this in kotlin?
p
What's wrong with that?
m
Copy code
removed?.let {
}
@xetra11?
🚫 1
x
ye do the let stuff with fancy kotlin nullables
its magic @Paul Woitaschek please join the magical side
p
Nah the code is fine like it is
👍 5
☝️ 1
Its easy to read and makes use of smart casts
1
👍 4
b
I'm with @Paul Woitaschek on this one. Let can be easily abused
x
@Big Chungus Do you have an example at hand?
b
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
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
Yes, but you can do multiple null checks in java style check
x
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
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:
Copy code
if (currency != null && rate != null) {
  result[currency] = rate
}
Is easier to understand than this:
Copy code
currency?.let {
  rate?.let { rate ->
    result[it] = rate
  }
}
16
x
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
if null check is almost always better than using let for null check