Skip to content

Instantly share code, notes, and snippets.

@2get
Last active August 29, 2015 14:04
Show Gist options
  • Save 2get/5f892fb4ccc5ca91eae4 to your computer and use it in GitHub Desktop.
Save 2get/5f892fb4ccc5ca91eae4 to your computer and use it in GitHub Desktop.
Ruby ===
p (1..5) === 3 #=> true レシーバは Range クラスのインスタンスだから、=== 演算子は引数が自身の範囲内に含まれるかを判定
p 3 === (1..5) #=> false レシーバは Fixnum クラスのインスタンスだから、=== 演算子は数値として等しいかを判定
p /おつかれ/ === 'おつかれさまです' #=> true レシーバは Regexp クラスのインスタンスだから、=== 演算子は引数の文字列がマッチするか判定
p 'おつかれさまです' === /おつかれ/ #=> false レシーバは String クラスのインスタンスだから、=== 演算子は同値判定
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment