I'd like to make my yearless dates class play nice with Range#include?, according to the docs, all it has to implement is <=>:
class Count
include Comparable
attr_reader :value
def initialize(value)
@value = value
end
def <=>(other)
value <=> other.value
end
end
Let's try on Ruby 3.1.1:
(Count.new(1)..Count.new(5)).include? Count.new(3)
# => in `each': can't iterate from Count (TypeError)
I don't get why it's trying to iterate here, each should not be necessary to figure out inclusion.
Any idea what am I doing wrong here? Thanks for your hints!
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)