I am trying to write a generic iterator that combines a Fibonacci sequence:
def FibIter[T](fst:T , snd:T)(implicit num:Numeric[T]) = new Iterator[T] { var fn1 = fst var fn2 = snd def hasNext = true def next() = { val ret = fn1 fn1 = fn2 fn2 = num.plus(ret,fn2) ret } }
However, the compiler complains about the first two assignments of variables:
A parameter type in a structural refinement may not be an abstract type defined outside this refinement
Does anyone have an idea how to solve this problem? Thank you very much!
source share