Rubyize This: Live in Vancouver. Refactoring #3
published Jan 27, 2008
Here’s the final refactoring from the Rubyize This workshop. See the first refactoring for an explanation of what’s going on and why this code is so darn ugly! The second refactoring is worth checking out as well.
This was the final refactoring, and the end of the conference, so we sort of ran out of time.
I didn’t get a change to show off my solution. Here it is.
What’s going on with that File.delete
call?
First, File.delete
takes multiple arguments and deletes all of them.
Second, I used the asterisk operator. From here:
“The asterisk operator may also precede an Array argument in a method call. In this case the Array will be expanded and the values passed in as if they were separated by commas.”
I don’t think I’ve every actually used the asterisk operator in production code, but it sure came in handy here.