New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Range toString is ridiculous #9656
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9656?orig=1 |
Rob Norris (rnorris) said: |
@som-snytt said: It's not like the max value for printing is some arbitrary value. private[immutable] val MAX_PRINT = 512 // some arbitrary value The question is why does it use JAVA_CONVENTIONS. You don't get any help from stringOf, where you can specify max, because // When doing our own iteration is dangerous
def useOwnToString(x: Any) = x match {
// Range/NumericRange have a custom toString to avoid walking a gazillion elements
case _: Range | _: NumericRange[_] => true The irony is that the REPL thinks a million elements is also too much, and inserts its own ellipsis. scala> 1123 to 273645 by 261
res1: scala.collection.immutable.Range = Range(1123, 1384, [snip] 29833, 30094, 3... If only there were a type class for this sort of thing... Call it the TrailingEllipsis type class... |
Stephen Robinson-Burns (stevorobs3) said: |
@som-snytt said: |
@SethTisue said: |
Stephen Robinson-Burns (stevorobs3) said: |
@som-snytt said: |
@szeiger said: |
The toString on Range prints out all the elements, unless there are too many in which case it gets truncated and you can't determine what the max value is. And you have to do the math in your head if you want to know what the step is.
I suggest that something like Range(start, stop, step) might be more useful.
The text was updated successfully, but these errors were encountered: