Created
October 15, 2014 01:57
-
-
Save murayama/821342ddd445c06902d4 to your computer and use it in GitHub Desktop.
rubyのrangeオブジェクトのinclude?とcover?の違い ref: http://qiita.com/murayama/items/bbd9237ccc88ceba49b1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
october = (Time.new(2014,10,1)..Time.new(2014,10,31)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
october.include? Time.now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TypeError: can't iterate from Time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
october.cover?(Time.now) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cover?(obj) -> bool | |
obj が範囲内に含まれている時に真を返します。 | |
Range#include? と異なり <=> メソッドによる演算により範囲内かどうかを判定します。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment