Skip to content

Instantly share code, notes, and snippets.

@scottweaver
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottweaver/bafb0b9fc7ac6ff68027 to your computer and use it in GitHub Desktop.
Save scottweaver/bafb0b9fc7ac6ff68027 to your computer and use it in GitHub Desktop.
Scala Problems
/*
* SUMMARY
* You have two case classes: One of the case classes, Settlement, may (via Option) contain
* the other one, TransactionInfo and TransactionInfo may contain a String.
*
* PROBLEM
* Provide a solution for checking whether or not the TransactionInfo's typeCode contained within
* the Settlement is one any one of the follwoing values "271", "272", "1", "0". In the case that either TransactionInfo or
* typeCode is None, the result should be false.
*
* HINTS
* - There are multiple ways to solve this. The goal is to find the most concise and functional way to solve the problem.
* - Make sure you account for the possibility of either (or both) TransactionInfo and typeCode not being set.
*/
case class TransactionInfo(typeCode: Option[String])
case class Settlement(txnInfo: Option[TransactionInfo])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment