Skip to content

Commit 9ca4635

Browse files
committed
Chapter 1 examples
1 parent cc52ed6 commit 9ca4635

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object FunctionUtil {
2+
def testFunction(f : Int => Int) : Int = f(5)
3+
}
4+
5+
abstract class AbstractFunctionIntIntForJava extends (Int => Int) {
6+
}
7+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class JavaFunction {
2+
public static void main(String[] args) {
3+
System.out.println(FunctionUtil.testFunction((scala.Function1<Integer,Integer>)new AbstractFunctionIntIntForJava() {
4+
public Integer apply(Integer argument) {
5+
return argument + 5;
6+
}
7+
}));
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
class JavaTest {
3+
public static void main(String[] args) {
4+
ScalaUtils.log("Hello!");
5+
ScalaUtils$.MODULE$.log("Hello!");
6+
System.out.println(ScalaUtils.MAX_LOG_SIZE());
7+
System.out.println(ScalaUtils$.MODULE$.MAX_LOG_SIZE());
8+
}
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object ScalaUtils {
2+
def log(msg : String) : Unit = Console.println(msg)
3+
val MAX_LOG_SIZE = 1056
4+
}

0 commit comments

Comments
 (0)