From: Robert Klemme Date: 2009-10-14T04:10:05+09:00 Subject: Re: Enumerating and mixin. On 13.10.2009 01:47, Rajinder Yadav wrote: > OK I managed to sweet the code down to the following, is there anything else I > missed? > > class Vowels > include Enumerable > def initialize > @list = %w(u e a o i) > end > > def each > @list.each { |item| yield item } > end > end > > obj = Vowels.new > > obj.each { |s| print s } > puts "" > obj.sort.each { |s| print s } > puts "" Two notes: you can actually pass the block directly on to method each of Array. def each(&b) @list.each(&b) end And: conventionally #each returns self. Taking both together you could do def each(&b) @list.each(&b) self end Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/