❔ Why does this code give the CS8604 warning?
I'm confused why the below code gives the CS8604 warning. As far as I am concerned, I am null checking so it shouldn't appear. How can I improve it?
17 Replies
Nullable flow analysis is not smart enough to figure that out when the result is stored in an intermediate variable.
Nullable flow analysis is not smart enough to figure that out when the result is stored in an intermediate variable.
i'm getting more and more convinced you're a bot
i'm getting more and more convinced you're a bot
If you did
if (myString != null)
or if (myString is not null)
then it would pick up on itIf you did if (myString != null) or if (myString is not null) then it would pick up on it
In my actual use case I've got some more complicated Boolean expressions and I need to name them something more self-documenting.
Well, you can do
myString!.Reverse()
which will force the compiler to just shut up because you know it won't be nullFor example
var turnHasChanged = _turnLastTick != null && _turnLastTick != turnThisTick;
Oh, that works!@Lexaro I've already had to deal with you once this morning - please clarify what you're doing
you have 5 minutes or I will assume you're self botting.
?????
why are you copypasting other people's messages?
I help people who have problems coding
ok
ok
I can see you're just not going to address the actual problem
!ban @Lexaro self bot
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.