operator

suggest change
if /hay/ =~ 'haystack'
  puts "There is hay in the word haystack"
end

Note: The order is significant. Though 'haystack' =~ /hay/ is in most cases an equivalent, side effects might differ:

Note that this does not return a true/false value, it instead returns either the index of the match if found, or nil if not found. Because all integers in ruby are truthy (including 0) and nil is falsy, this works. If you want a boolean value, use #=== as shown in another example.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents