From: rtilley Date: 2006-03-20T22:28:49+09:00 Subject: Digest::Base I wish to write one method to work with all classes in Digest::Base without repeatedly writing the same code. def setup(file, hash_type) # hash_type could be MD5, SHA1, SHA256, etc. Digest::hash_type.new Hash the file. end The above example is what I'd like to be able to do, but it does not work. I cannot insert 'hash_type' into the method in this manner. Trying to do so produces errors. I can do a bunch of conditionals like this: def setup(file, hash_type) if hash_type == MD5 Digest::MD5.new Hash the file. elsif hash_type == RMD160 Digest::RMD160.new Hash the file. else.... .... end But then, I begin repeating myself. Any tips on making this work with fewer lines of code? Thanks!