Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
scala> import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.ArrayBuffer
scala> case class CustomList[A](elements: A*) {
|
| val elems = new ArrayBuffer[A]
| elems ++= elements
| }
defined class CustomList
scala> val list = CustomList(1, 2, 3)
list: CustomList[Int] = CustomList(WrappedArray(1, 2, 3))
scala> for( i <- list) { println(i) }
<console>:14: error: value foreach is not a member of CustomList[Int]
for( i <- list) { println(i) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment