Skip to content

lengthCompare is said in doc to take seq as param but does not #515

Closed
@bjornregnell

Description

@bjornregnell

Here:
http://docs.scala-lang.org/overviews/collections/seqs.html
This example is given:

xs.lengthCompare ys "Returns -1 if xs is shorter than ys, +1 if it is longer, and 0 is they have the same length. Works even if one if the sequences is infinite."

(BTW: the example should not have a dot in operator syntax)

When I do this:
$ scala
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_66).
Type in expressions for evaluation. Or try :help.

scala> val xs = (1 to 10).toVector
xs: Vector[Int] = Vector(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

scala> xs lengthCompare 10
res0: Int = 0

scala> xs lengthCompare xs
:13: error: type mismatch;
found : Vector[Int]
required: Int
xs lengthCompare xs
^
Is the method signature wrong or is the overview doc wrong? Should the parameter be an Int or another sequence?
I can try to fix it, if it is the overview doc, with some guidance of how to...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions