我有一个泛型类Book[T](index: Int, type: T)
和一个foo
类型的对象Book
。我不确定如何访问索引和类型。我试过了:
1. foo match { case Book[T](index: Int, type:T) => {} }
2. foo match { case Book(index: Int, type:T) => {} }
3. foo match { case foo: Book[T] => { foo.index } }
全部失败并显示消息:
1. class Book does not take type parameters
2. class Book not found
3. index is not a member of Book
谢谢你。