From: Charles Nutter Date: 2011-01-12T02:35:56+09:00 Subject: [ruby-core:34368] [Ruby 1.9-Feature#4264] General type coercion protocol for Ruby Issue #4264 has been updated by Charles Nutter. Tom Enebo proposed (in an offhand way) an additional #to? that simply returns whether the coercion would succeed. So the following code: obj.to_str if obj.respond_to? :to_str Would become obj.to(String) if obj.to?(String) Some backstory on why I like this idea: In JRuby we often have to choose from multiple method overloads with different types of parameters. Having a to? protocol would be necessary for us to allow users to define their own java coercions, since without to? we won't know which types they support (without potentially forcing them to coerce, an expensive operation before we've decided that we have found the right overload to invoke). ---------------------------------------- http://redmine.ruby-lang.org/issues/show/4264 ---------------------------------------- http://redmine.ruby-lang.org