Created
January 9, 2018 13:49
-
-
Save harmeetsingh0013/0db9a1361fbd13213a19c63727ac001e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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