The toString() method on arrays is generally unhelpful (inherited from Object.) Since jshell is a read-eval-PRINT loop, it might be nice to print the result of array-valued expressions in a friendlier manner, such as by using Arrays.toString(array) instead of array.toString(). (Might want to limit this to arrays of below a certain length. (Might want to allow that limit to be set by preferences.))
So we'd get
[ 1, 2, 3 ]
instead of
[I@2048230
-Brian
Yes, please limit (i had also this noted down for another review round). It would be aesthetically pleasing to align the output to fit into an equal number of R rows for Math.min(R * C, MAX_CHARS);
Paul.
If arrays are big, how about printing "the first few" and "the last few", separate by "...", as in
[ 1, 2, 3, ..., 98, 99, 100 ]
-- Jon
Same applies to Collection as well (not sure we can always do the same for Iterable given it might be traversable once only in some rare cases).
I think there should also be truncation for toString beyond a certain length e.g.: it could be something like (aligned to the columns for a certain number of rows):
-> Stream.generate(() -> "A").limit(10000).collect(Collectors.joining(""));
| String $1 = âAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA..."
-Paul
So we'd get
[ 1, 2, 3 ]
instead of
[I@2048230
-Brian
Yes, please limit (i had also this noted down for another review round). It would be aesthetically pleasing to align the output to fit into an equal number of R rows for Math.min(R * C, MAX_CHARS);
Paul.
If arrays are big, how about printing "the first few" and "the last few", separate by "...", as in
[ 1, 2, 3, ..., 98, 99, 100 ]
-- Jon
Same applies to Collection as well (not sure we can always do the same for Iterable given it might be traversable once only in some rare cases).
I think there should also be truncation for toString beyond a certain length e.g.: it could be something like (aligned to the columns for a certain number of rows):
-> Stream.generate(() -> "A").limit(10000).collect(Collectors.joining(""));
| String $1 = âAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA..."
-Paul
- duplicates
-
JDK-8166400 JShell: friendlier representation of array values
- Closed
-
JDK-8154812 jshell tool: value printing truncation
- Closed
- relates to
-
JDK-8173807 JShell: control characters should be escaped in String values
- Closed