Search code examples
rubyrubymine

RubyMine: "Expression can be simplified" But how?


How to simplify this expression?

m.immutable = params[:immutable] || false

RubyMine suggests: "Expression can be simplified. This inspection warns about redundant parts inside boolean function", but doesn't say what to do.

The idea is to assign false if "immutable" parameter wasn't passed.


Solution

  • Just click Alt+Enter and RubyMine will show

    m.immutable = params[:immutable]
    

    In some cases this can help you, but if you are not passing param then immutable will be nil, which could be not what your expecting