How to suppress "local variable 'foo' can be uninitialized"

Answered

There is a "local variable 'foo' can be uninitialized" if I write like

 

foo if boolean_value

p foo

 

How can I suppress this warning?

I couldn't find configuration for it.

 

6 comments

+1 ... Rubymine is complaining the value may be uninitialized when using the safe navigation operator or wrapping the variable access inside an if statement.

0

Hello, sorry for delay! could you please attach the screenshots of the code with inspection? I'm unable to reproduce unfortunately.

0

@Mrtmrt15xn,

would it be possible to provide a code sample?

0

@Olga-Kuvardina

See the image below.

I know that the variable can be uninitialized. But I just want to hide the warning.

0

@Mrtmrt15xn, you can invoke intention action (Alt+Enter) and suppress that inspection for the method.

0

Please sign in to leave a comment.