What i stumbled upon just now - how to easily limit verity of classes that are passed to one method to only one class type ? ex. code:
class S
attr_reader :s
def initialize(s = nil)
@s = s || 14
end
end
class Gets
def self.read(s)
s.s
end
end
s=S.new
p Gets.read(s) # 14
Let's say that class S has a more complex structure and i want to be sure that only that class could be passed to Gets#read
method, how can i do that?