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
trait Searchable { | |
def search(query: SearchQuery): Seq[SearchResults] | |
} | |
trait PaginationWithNominalType { | |
this: Searchable => | |
def page(query: SearchQuery, pageSize: Int, pageNum: Int) = { | |
search(query).grouped(pageSize).toList(pageNum) | |
} | |
} |
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
//create a map | |
val cars = Map("james" -> "BMW", "ike" -> "Infiniti", "stephen" -> "Buick") | |
//create a map from an Array | |
//Scala does not provide a convenience method to do this... :( | |
val carArray = Array("james", "BMW", "ike", "Infiniti", "stephen", "Buick") | |
val cars = carArray.grouped(2).toList.map(c => (c.head,c.last)).toMap | |
//mapping over a map | |
//transform all string keys to symbols (interned strings) |