如何为以下archive_all
函数编写签名?
# typed: true
extend T::Sig
module Archivable
def archive
end
end
class Book
extend Archivable
end
class Magazine
extend Archivable
end
sig {params(klass: T.class_of(Archivable)).void}
def archive_all(klass)
klass.archive
end
archive_all(Book)
archive_all(Magazine)
冰糕错误:
editor.rb:17: Method archive does not exist on T.class_of(Archivable) https://srb.help/7003
17 | klass.archive
^^^^^^^^^^^^^
editor.rb:5: Did you mean: Archivable#archive?
5 | def archive
^^^^^^^^^^^