class Foo
def foooo
"Foo#fooo"
end
end
class Bar
def fooo # 残念oが一つ足りない!
"Bar#foooo"
end
end
module Hoge
def self.hoge(*fooo_ables)
fooo_ables.each{|fooo_able| puts fooo_able.foooo}
end
end
Hoge.hoge(Foo.new, Bar.new) # 実行時エラー!!class Foo{
def foooo = "Foo#fooo"
}
class Bar{
def fooo = "Bar#fooo"
}
object Hoge{
type HasFoooo = { def foooo: String }
def hoge(hasFoooos: HasFoooo*) = {
hasFoooos.foreach{ hasFoooo => println(hasFoooo.foooo) }
}
}
object Duck extends App{
Hoge.hoge(new Foo) // 問題ない
Hoge.hoge(new Foo, new Bar) // コンパイルエラー!
}