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
val sum = collectionOfNumbers.sum |
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
int sum = 0; | |
for (int n : collectionOfNumbers) { | |
sum += n; | |
} |
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
def txn(block: => Unit): Unit = { | |
val transaction = new Transaction | |
try { | |
transaction.begin() | |
block | |
transaction.commit() | |
} |
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
txn { | |
println("I am in transaction, safe and sound!") | |
} |
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
Transaction t1 = new Transaction(); | |
t1.begin(); | |
try { | |
System.out.println("I am in transaction, safe and sound!"); | |
t1.commit(); | |
} catch (Exception ex) { | |
t1.rollback(); | |
} |
NewerOlder