I try to find out the purpose of underscore in method argument but not find any reason. Like there is a method
def eligible(user)
end
and same method but with an underscore in argument
def eligible(_user)
end
whats the difference between them
CodePudding user response:
It's just code convention to underscore a variable if you're not gonna use it later on. It has no meaning otherwise.
Use _ for unused variables.
from ... https://clearwater.readthedocs.io/en/stable/Clearwater_Ruby_Coding_Guidelines.html#naming
Also see this for further reading on style preferences. https://github.com/rubocop/ruby-style-guide