Hi, At Tue, 7 Jun 2005 01:00:23 +0900, Eric Mahurin wrote in [ruby-talk:144691]: > Regarding duck-typing... Is there an easy way make a "duck"? > i.e. an object that responds to enough methods to be an > acceptable argument to a certain methods. For example, if I > have a method that takes aString and uses the #size and #[i] > methods, I could pass it something that looked just enough like > a String to work: > > alphabet = Object.duck(:[],proc{|i|?a+i},:size,proc{26}) I'd posted a feature called `behavior' in [ruby-dev:25772]. alphabet = Object.behaving(:[]) {|i|(?a+i).chr} p alphabet[20] #=> "u" -- Nobu Nakada