Skip to content

Instantly share code, notes, and snippets.

@murayama
Created October 15, 2014 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save murayama/821342ddd445c06902d4 to your computer and use it in GitHub Desktop.
Save murayama/821342ddd445c06902d4 to your computer and use it in GitHub Desktop.
rubyのrangeオブジェクトのinclude?とcover?の違い ref: http://qiita.com/murayama/items/bbd9237ccc88ceba49b1
october = (Time.new(2014,10,1)..Time.new(2014,10,31))
october.include? Time.now
TypeError: can't iterate from Time
october.cover?(Time.now)
cover?(obj) -> bool
obj が範囲内に含まれている時に真を返します。
Range#include? と異なり <=> メソッドによる演算により範囲内かどうかを判定します。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment