What is the “=~” operator in Ruby?

前端 未结 7 678
情深已故
情深已故 2020-12-01 09:56

I saw this on a screencast and couldn\'t figure out what it was. Reference sheets just pile it in with other operators as a general pattern match operator.

7条回答
  •  青春惊慌失措
    2020-12-01 10:43

    Regular expression string matching:

    puts true if url =~ /google.com/

    You can read '=~' as 'is matching'.

提交回复
热议问题