Skip to content

Instantly share code, notes, and snippets.

@harmeetsingh0013
Created January 9, 2018 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harmeetsingh0013/0db9a1361fbd13213a19c63727ac001e to your computer and use it in GitHub Desktop.
Save harmeetsingh0013/0db9a1361fbd13213a19c63727ac001e to your computer and use it in GitHub Desktop.
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