Hi,
 Your solution will test true ( 0, in your case )
for "bbb".consists_of("abc").  Is that what you want?

Here's a different solution that will only return true if
the two words have the exact same length and the 
exact same letters:

def consists_of? (other)
 a = self.split(//)
 b = other.split(//)
 a.sort == b.sort
end

FWIW,
Barry


> > I'm sorry; it would be way better to have a boolean method, like:
> > "abc".consists_of?("abc") # -> true
> > "acb".consists_of?("abc") # -> true
> > "bac".consists_of?("abc") # -> true
> > "bca".consists_of?("abc") # -> true
> > 
> > And then, how can I say
> > 
> > word_list = ['foo', 'bca']
> > word_list.include? word_consisting_of('abc')
> > # => true
> 
> 
> This seems to do the trick:
> 
> class String
>    def consists_of word
>      self =~ /[#{word}]{#{word.length}}/
>    end
> end
> 
> class Array
>    def get_words_consisting_of word
>      select do |item|
>        item.consists_of word
>      end
>    end
> end
> 
> Tobi
> 
> 
> 
> -- 
> 
> * peace&love.
> * http://www.pinkjuice.com/
>