eaplatanios / tensorflow_scala

TensorFlow API for the Scala Programming Language
http://platanios.org/tensorflow_scala/
Apache License 2.0
939 stars 95 forks source link

The `::` val shadows the `::` List constructor #189

Open coreyoconnor opened 4 years ago

coreyoconnor commented 4 years ago

This :: value: https://github.com/eaplatanios/tensorflow_scala/blob/master/modules/api/src/main/scala/org/platanios/tensorflow/api/package.scala#L80

Will shadow the :: List constructor. The List is a commonly used type from the Scala predef so removing the usability of :: is unexpected.

for example:

import org.platanios.tensorflow.api._
val oh :: no = List(1, 2)

will fail with

cmd0.sc:1: value :: is not a case class, nor does it have an unapply/unapplySeq member
coreyoconnor commented 1 year ago

Alternatively: Always use +: ( https://www.scala-lang.org/api/current/scala/collection/package$$$plus$colon$.html ) as the pattern matcher. Does not match exactly on the cons case class but, for most uses, has the same effect and is generic across Seq types