I know I can use %w() as a shortcut to create an array. E.g. these should be equivalent:
FOO = %w(dog, cat)
BAR = ["dog", "cat"]
But when I use include
to check what's included in these arrays:
FOO = %w(dog, cat)
BAR = ["dog", "cat"]
puts FOO.include? "dog" #false
puts BAR.include? "dog" #true
The first puts
returns false
while the second one returns true
. Why is this happening?