Ruby/Rubymine best practice for Hash.delete_if unused variables

I'm trying to overhaul my codebase here to make better use of warnings that Rubymine is giving us, and I'd like to make use of the unused local variable ones but am running into some cases that seem tricky.

Let's say you have:

a = {a: 1, b: 2, c: 3}
a.delete_if { |key, value| value >=2 }

Rubymine will of course complain that you have an unused local variable named key.  The lightbulb suggests turning this into a wildcard _ variable, but that seems kind of strange to me.  Is that really the best practice here?  Is there a better way to handle this?

Thanks,
Steve Wollkind

0
2 comments

AFAIK using _ for unused params is a common practice.

Oleg.

0

Thanks, Oleg!

0

Please sign in to leave a comment.