Created
April 21, 2018 04:27
-
-
Save clhodapp/c9cf33d10869e021ef2e0ac7cee0b5f6 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 | |
Welcome to Scala 2.12.4 (OpenJDK 64-Bit Server VM, Java 1.8.0_121). | |
Type in expressions for evaluation. Or try :help. | |
scala> :paste | |
// Entering paste mode (ctrl-D to finish) | |
case class Setting[T]( | |
key: String, | |
value: T | |
) | |
object ProjectExtra { | |
def inThisBuild(ss: Seq[Setting[_]]): Seq[Setting[_]] = ss | |
def inThisBuild[T](ts: T*)(implicit ev: T <:< Setting[_]): Seq[Setting[_]] = ts.map(ev.apply) | |
} | |
// Exiting paste mode, now interpreting. | |
defined class Setting | |
defined object ProjectExtra | |
scala> ProjectExtra.inThisBuild(List(Setting("foo", 3), Setting("bar", "bar"))) | |
res0: Seq[Setting[_]] = List(Setting(foo,3), Setting(bar,bar)) | |
scala> ProjectExtra.inThisBuild(Setting("foo", 3), Setting("bar", "bar")) | |
res1: Seq[Setting[_]] = ArrayBuffer(Setting(foo,3), Setting(bar,bar)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment