I have a List(fruits) that I want to find and print the reference(memory address) of it, How can I?
val fruits:List[String]=List("apple","orange","pear")
I have a List(fruits) that I want to find and print the reference(memory address) of it, How can I?
val fruits:List[String]=List("apple","orange","pear")
It is not really clear what you mean by references. A String is already A reference. If you want to unrefine it ("forget" that the underlying structure is a String) and just have a pure reference you can rely on the fact that the type parameter of a list if covariant and List[String] is a subtype of List[AnyRef].
val refs: List[AnyRef] = fruits
Not sure why this would be useful tho. Not much you can do with references.