This file contains hidden or 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 log(flag: Boolean)(op: String) { | |
| val writer = new java.io.PrintWriter(System.out) | |
| try { | |
| if(flag) writer.println(op) | |
| else writer.println("flag off") | |
| } | |
| finally { | |
| writer.close() | |
| } | |
| } |
This file contains hidden or 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 log(flag: Boolean)(op: () => String) { | |
| val writer = new java.io.PrintWriter(System.out) | |
| try { | |
| if(flag) writer.println(op) | |
| else writer.println("flag off") | |
| } | |
| finally { | |
| writer.close() | |
| } | |
| } |
This file contains hidden or 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 log(flag: Boolean)(op: => String) { | |
| val writer = new java.io.PrintWriter(System.out) | |
| try { | |
| if(flag) writer.println(op) | |
| else writer.println("flag off") | |
| } | |
| finally { | |
| writer.close() | |
| } | |
| } |
This file contains hidden or 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 log(op: => String) { | |
| val writer = new java.io.PrintWriter("log.txt") | |
| try { | |
| val result = op | |
| writer.println(result) | |
| } | |
| finally { | |
| writer.close() | |
| } | |
| } |
This file contains hidden or 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 log(op: () => String) { | |
| val writer = new java.io.PrintWriter("log.txt") | |
| try { | |
| val result = op() | |
| writer.println(result) | |
| } | |
| finally { | |
| writer.close() | |
| } | |
| } |
This file contains hidden or 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
| class Function implements Runnable { | |
| @Override | |
| public void run() { | |
| System.out.println("hello!"); | |
| } | |
| } | |
| public class Main { | |
| public static void main(String[] args) { |
This file contains hidden or 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
| class Rectangle3(val width: Int,height: Int) { | |
| println(s"2:width = $width height = $height") | |
| def this(size : Int) { | |
| this(size,size) | |
| println(s"Square width = height = $width") | |
| } | |
| def getArea: Int = { | |
| width * height |
This file contains hidden or 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
| class Rectangle0 { | |
| val width: Int = 100 | |
| val height: Int = 200 | |
| println(s"1:width = $width height = $height") | |
| } | |
| class Rectangle1(val width: Int,height: Int) { | |
| println(s"2:width = $width height = $height") | |
| def this(size : Int) { |
This file contains hidden or 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 states = Map( | |
| "1" -> "北海道", | |
| "2" -> "青森県", | |
| "3" -> "岩手県", | |
| "4" -> "宮城県", | |
| "5" -> "秋田県", | |
| "6" -> "山形県", | |
| "7" -> "福島県", | |
| "8" -> "茨城県", | |
| "9" -> "栃木県", |
This file contains hidden or 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 log(op: () => String) { | |
| val writer = new java.io.PrintWriter("log.txt") | |
| try { | |
| val result = op() | |
| writer.println(result) | |
| } | |
| finally { | |
| writer.close() | |
| } | |
| } |
NewerOlder