aboutsummaryrefslogblamecommitdiff
path: root/tests/run/puzzler54.scala
blob: 9dd4cbb47832ca8f10fefbdaf470daf42bc14375 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                                
// Scala Puzzler 54
object Test {
  case class Card(number: Int, suit: String = "clubs") {
    val value = (number % 13) + 1 // ace = 1, king = 13
    def isInDeck(implicit deck: List[Card]) = deck contains this
  }

  def main(args: Array[String]) = {
    implicit val deck = List(Card(1, "clubs"))
    implicit def intToCard(n: Int): Card = Card(n)
    assert(1.isInDeck)
  }
}