foo = ''
foo = 'hi there'
This is part paranoia, and part clarity. In this trivial example there's unlikely to be an issue, but what if you had this?
begin foo = complicated_method_call(with: lots_of_arguments, and: another_call(with: args)) rescue end
A whole bunch of stuff could go wrong there, and if that's the case you end up with
Now, using a blind
rescue is generally bad form, you ideally want to scope down to just the ones your code might trigger.
Remember Ruby variables are defined at the method level, any instance of them in the method makes them defined, but they will have a default of
nil which can be undesirable.