Skip to content

Instantly share code, notes, and snippets.

@drulabs
Last active August 8, 2018 06:18
Show Gist options
  • Save drulabs/1c9526320f4802fbc7540bf1ccbefa5a to your computer and use it in GitHub Desktop.
Save drulabs/1c9526320f4802fbc7540bf1ccbefa5a to your computer and use it in GitHub Desktop.
class NEFT: Transaction ... // class NEFT extends Transaction
class IMPS: Transaction ... // class IMPS extends Transaction
class RTGS: Transaction ... // class RTGS extends Transaction
val transaction: Transaction = getCurrentTransaction()
// Now we don't know the type of transaction. It could be either of NEFT, IMPS or RTGS
// So we need to identify the type of trsaction and process it accordingly
when (transaction) {
is NEFT -> transaction.processNEFT()
is IMPS -> transaction.processIMPS()
else -> println("No Processing required")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment