scala.collection.immutable.WrappedString need an implicit CanBuildFrom to fulfill documented features? -
wrappedstring scaladoc 2.8.1:
"this class serves wrapper augmenting strings operations found in indexed sequences. difference between class , stringops calling transformer methods such filter , map yield object of type wrappedstring rather string"
scala> import scala.collection.immutable.wrappedstring import scala.collection.immutable.wrappedstring scala> val s = new wrappedstring("foo") s: scala.collection.immutable.wrappedstring = wrappedstring(f, o, o) scala> s.filter(x => true) res1: scala.collection.immutable.wrappedstring = wrappedstring(f, o, o) scala> s.map(x => x) res2: scala.collection.immutable.indexedseq[char] = vector(f, o, o)
alas, map returns vector , not wrappedstring. if understand correctly:
filter works since uses newbuilder method, map needs implicit canbuildfrom wrappedstring bitset has. bug in code or documentation or missing something?
also, scaladoc simplified version doesn't make sense me:
def map [b] (f: (char) ⇒ b) : wrappedstring[b] def map [b, that] (f: (char) ⇒ b)(implicit bf: canbuildfrom[wrappedstring, b, that]) :
shouldn't be:
def map [b] (f: (char) ⇒ char) : wrappedstring def map [b, that] (f: (char) ⇒ b)(implicit bf: canbuildfrom[wrappedstring, b, that]) :
?
the first bug, 1 shall fixed 2.9.
Comments
Post a Comment