From 6083bca0a8c66ab8ec607bf8d66de5f0fd53637f Mon Sep 17 00:00:00 2001 From: Dmitriy Non Date: Tue, 15 Oct 2019 10:03:35 +0100 Subject: [PATCH] [ruby][case] Add a note about === A bit advanced but required knowledge about the magic in `case` --- sheets/_ruby/case | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sheets/_ruby/case b/sheets/_ruby/case index 966439e..589bcb2 100644 --- a/sheets/_ruby/case +++ b/sheets/_ruby/case @@ -31,3 +31,16 @@ when /food/ when /doe/ puts "#{str}, a female deer" end + +# Please note that `case` uses `===` operator to match values. +# The following are equivalent: +case x +when Integer then "I'm a number" +when String then "I'm a text" +end + +if Integer === x + "I'm a number" +elsif String === x + "I'm a text" +end