I am working on some code which checks whether or not to unlink a file on the basis of the class:
File.unlink(file.path) if file.is_a? File
I think it would be more idiomatic to check whether the object responds to the unlink
message:
File.unlink(file.path) if file.respond_to? :unlink
Is there any good reason to prefer the is_a?
approach?
is_a?
hack. I thought that perhapsrespond_to?
would be a more idiomatic approach in the interim. \$\endgroup\$