i'm trying implement simple subclass of iterable[string], , i'm encountering seems bit strange me. code follows:
class itstring[string] extends iterable[string]{ override def iterator: iterator[string] = new iterator[string] { def hasnext = true def next = "/" } } my ide complains it's expecting string it's of type string, , when trying compile, further reveals problem requires string literal of type java.lang.string. now, can fix changing "/".asinstanceof[string], i'd know why scala isn't recognising type correctly.
since can following compile:
class itstring extends iterable[string] { override def iterator: iterator[string] = new iterator[string] { def hasnext = true def next = "/" } } i can deduce problem writing:
class itstring[string] extends ... what's going on occurrence of string doesn't refer type java.lang.string, instead unknown parameterised type (like t or a). so, when write [string], means some unknown type determined implementing class rather the string type intended.
Comments
Post a Comment