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

Improve REPL display of String values #8603

Open
scabug opened this Issue May 19, 2014 · 3 comments

Comments

Projects
None yet
1 participant
@scabug
Copy link

scabug commented May 19, 2014

Copied from SUGGEST-30:

In Scala REPL (interactive interpreter), type this:

scala> Set(1, "1.2")
res11: scala.collection.immutable.Set[Any] = Set(1, 1.2)

The result does not put a quote on "1.2". Then the user cannot easily see what type each member is in the set. In addition, for the following:

scala> Set(1, "1.2 ")
res15: scala.collection.immutable.Set[Any] = Set(1, "1.2 ")

Quotes are added for string with leading/trailing whitespaces. This adds inconsistency. Also considering the following:

scala> Set(1, "1.2, 55")
res18: scala.collection.immutable.Set[Any] = Set(1, 1.2, 55)

Isn't the result confusing?

Please consider always adding quotes on strings in REPL result. Thank you.

PS: Original google group post for this issue is here:
https://groups.google.com/forum/#!topic/scala-user/xiXpEsCtnoA

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 19, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8603?orig=1
Reporter: @som-snytt
Affected Versions: 2.11.0
See #6592

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 19, 2014

@som-snytt said:
Example confusion, compounded by quoting.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Apr 19, 2015

Li Haoyi (lihaoyi) said:
This is fixed in the Ammonite REPL

@  Set(1, "1.2")
res8: scala.collection.immutable.Set[Any] = Set(1, 1.2)
@ Set(1, "1.2 ")
res9: scala.collection.immutable.Set[Any] = Set(1, 1.2 )
@ Set(1, "1.2, 55")
res10: scala.collection.immutable.Set[Any] = Set(1, 1.2, 55)
@ Set("1", "1.2")
res11: scala.collection.immutable.Set[java.lang.String] = Set("1", "1.2")
@ Set("1", "1.2 ")
res13: scala.collection.immutable.Set[java.lang.String] = Set("1", "1.2 ")
@ Set(1, 1.2)
res12: scala.collection.immutable.Set[Double] = Set(1.0, 1.2)

As you can see, Set[Any] behavior still isn't great, but most people don't deal with Anys much anyway. Set[T] for any strongly-typed T is pretty-printed properly in the same way a literal would be written

@scabug scabug added this to the Backlog milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment