-
-
Save Yuichiroh/8c66e6a0bf446a95a570 to your computer and use it in GitHub Desktop.
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
import scala.util.continuations._ | |
def using[A <: {def close()}](resource: A)(op: A => Unit) = { | |
try { | |
Console.err.println("op") | |
op(resource) | |
} | |
finally { | |
Console.err.println("close") | |
resource.close() | |
} | |
} | |
reset { | |
val w1 = shift(using(new PrintWriter("col1.txt"))) | |
val w2 = shift(using(new PrintWriter("col2.txt"))) | |
Console.err.println("A") | |
Source.stdin.getLines().map(_.split("\t")).foreach { | |
case Array(col1, col2, _*) => | |
w1.println(col1) | |
w2.println(col2) | |
case Array(col1) => w1.println(col1) | |
} | |
Console.err.println("B") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment