Skip to content

Instantly share code, notes, and snippets.

@bwmcadams
Created June 9, 2011 15:20
Show Gist options
  • Save bwmcadams/1016955 to your computer and use it in GitHub Desktop.
Save bwmcadams/1016955 to your computer and use it in GitHub Desktop.
Defaults + Type Classes
/**
* Attempting to factor this method (Which used to take a hard argument for Qry of BSONDocument
* to use a type class, where the type class object SerializableBSONObject knows how to encode/decode the
* Document represented in Qry
*
* I was ***hoping*** That the Scala compiler would be smart enough to extract the type class type
* in the case of a Default Argument but it seems not.
* The compiletime error is:
*
* could not find implicit value for evidence parameter of type org.bson.SerializableBSONObject[Nothing]
*
* A cookie and/or mug of tasty beer for anyone who has clever ideas that don't involve
* java style overloaded methods
*/
def findAndRemove[Qry : SerializableBSONObject](db: String)(collection: String)(query: Qry = Document.empty) = findAndModify(db)(collection)(query=query, remove=true)_
@bwmcadams
Copy link
Author

bwmcadams commented Jun 9, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment