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.

 

7 comments
Comment actions Permalink

+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
Comment actions Permalink

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

0
Comment actions Permalink

+1

I can't suppress it, too.

0
Comment actions Permalink

@Mrtmrt15xn,

would it be possible to provide a code sample?

0
Comment actions Permalink

@Olga-Kuvardina

See the image below.

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

0
Comment actions Permalink

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

1
Comment actions Permalink

Thanks. It works.

0

Please sign in to leave a comment.