- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Return type problem.
Thu, 2012-01-12, 13:22
class ComplexCurveSecuritiesCollection[T <: SecurityImpl,X<:TermStructure](private val subcollections: IndexedSeq[GenericCurveSecuritiesCollection[T,X]]) extends CurveSecuritiesCollection[T] {
type SubType = ComplexCurveSecuritiesCollection[T,X]
type TermStructureType = X
def filter(f: (T) => Boolean) = { val newCollections = subcollections.map(item=>item.filter(f)); new ComplexCurveSecuritiesCollection[T,X](newCollections); }
}
error: type mismatch;found : IndexedSeq[com.gottex.gottware.common.datamodels.finance.collections.curves.CurveSecuritiesCollection.GenericCurveSecuritiesCollection[T,X]#SubType] required: IndexedSeq[com.gottex.gottware.common.datamodels.finance.collections.curves.CurveSecuritiesCollection.GenericCurveSecuritiesCollection[T,X]]new ComplexCurveSecuritiesCollection[T,X](newCollections);
where
trait CurveSecuritiesCollection[T <: SecurityImpl] extends RepriceableAndPublisheableCollection with java.lang.Iterable[T] {
type SubType <: CurveSecuritiesCollection[T]
def filter(f: (T) => Boolean): SubType
}
What is wrong in my code?
Best RegardsEdmondo Porcu