Skip to content

dotty REPL shows the Array hexcode instead of actual elements #4067

Closed
@prayagupa

Description

@prayagupa

Minor issue that dotty REPL shows "hex representation of hashcode" of the array instead of showing elements in it.

scala> val data = Array(1, 3, 5, 7, 11).map(x => x * x) 
val data: Array[Int] = [I@6eda012b
scala> data.toString 
val res11: String = "[I@6eda012b"

while "scalac REPL" shows the elements which I think is expected in REPL.

scala> val data = Array(1, 3, 5, 7, 11).map(x => x * x)
data: Array[Int] = Array(1, 9, 25, 49, 121)

scala> data.toString
res11: String = [I@3071d086

Seq works fine in dotty REPL.

scala> Seq(1, 3, 5, 7, 11).map(x => x * x) 
val res12: Seq[Int] = List(1, 9, 25, 49, 121)

Solution probably is to use java.lang.Arrays.toString or different toString.

scala> java.util.Arrays.toString(Array(1, 3, 5, 7, 11)) 
val res19: String = "[1, 3, 5, 7, 11]"

environment

$ dotc -version
Dotty compiler version 0.6.0-RC1 -- Copyright 2002-2018, LAMP/EPFL

$ dotr -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions