samedi 4 avril 2020

Include method in Ruby applied on an Array

I am having some trouble with the include? method in ruby. As I understand this method should return true if the array includes the specified element. Like this:

                          a = [ "a", "b", "c" ]
                          a.include?("b")   #=> true
                          a.include?("z")   #=> false`

But when I do this :

                   soap_opera = ["all", "my", "children"]
                   p soap_opera.include?("a")

It returns false. Why?

Aucun commentaire:

Enregistrer un commentaire