Il giorno Sun, 22 Jan 2012 05:46:00 +0900
josh smith <use_this_123 / hotmail.com> ha scritto:

> Hi,
> 
> So im a newb to ruby. Just started learning today morning.
> I tried the following two cases but can not figure out why the outputs
> are different.
> 
> [°»recycler°…].include?(°∆recycle°«)
> 
> False
> 
> °»recycler°….include?(°∆recycle°«)
> 
> True
> 
> 
> Thank you
> 

The first line asks the array ["recycler"] whether it includes the element
'recicle'. This means that you're calling the method Array#include? . If you
look at its documentation, you'll see that it returns true only if one of the
elements of the array is equal as the argument. In your example, the array
contains a single argument, "recycler", which is different from the argument
('recycle).

When calling "recycler".include?('recycle'), instead, you're calling the
method String#include?, which returns true if the string contains the
argument. Since the word "recycler" contains the word "recycle", in your
example, it returns true.

I hope this helps

Stefano