Created
August 4, 2013 21:59
-
-
Save lanceon/6152125 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
object VarargTest { | |
abstract class OptionBase | |
case class Width(s: String) extends OptionBase | |
case object HasSearch extends OptionBase | |
case class Title(s: String) extends OptionBase | |
implicit def strToOption(s:String) : OptionBase = Title(s) | |
def func(options: OptionBase*) { | |
options.foreach(o => println("option = [%s]".format(o))) | |
} | |
def main(args: Array[String]) { | |
func() | |
func("String promoted to Title()") | |
func(Title("My title")) | |
func(Title("Another title"), HasSearch) | |
func(Width("100px")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment