[ruby][case] Add a note about ===

A bit advanced but required knowledge about the magic in `case`
pull/74/head
Dmitriy Non 5 years ago committed by GitHub
parent ed061663ba
commit 6083bca0a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

Loading…
Cancel
Save