is it possible to write a contract where somthing ...
# announcements
t
is it possible to write a contract where somthing implies, that a method will not return
null
? (all examples i can find implie the other way round)
l
I think that if by design your method can either be nullable or no-nullable, depending on a variable
Maybe your design is not correct, and you should refactor the two cases
t
damn, that would be far easier, thats right 😄
l
Can you show us an example of what you're trying to do?
t
in fact you are just right - i should split it into two methods. you know that sitautions where you feel really stupid for not seeing the obvious? 😂
s
Oh... we've all been there, Malte! :-D
l
And we'll be there many more times
Classic http://xyproblem.info/ perhaps?
t
na not really... the emssage has a boolean flag (which is bad on it's own, too), and when it's
false
it will return a non-null value - always. i knew this smeels before, but then i saw a colleague using it, and he had to use
?.
all over the place and i though "hey this is kotlin! it has a cool feature that might solve this problem" and didn't realise it would be much easier to simply split the method into two
so... maybe.. it's excactly the problem 🤷
l
I like how Kotlin makes some code smells even more smelly hahaha
😁 1
t
😄