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
| harmeet@harmeet-Vostro-3558:~/akka-samples/akka-cinammon$ sbt run | |
| [info] Loading global plugins from /home/harmeet/.sbt/0.13/plugins | |
| [info] Loading project definition from /home/harmeet/akka-samples/akka-cinammon/project | |
| [info] Set current project to akka-cinammon (in build file:/home/harmeet/akka-samples/akka-cinammon/) | |
| [warn] Multiple main classes detected. Run 'show discoveredMainClasses' to see the list | |
| Multiple main classes detected, select one to run: | |
| [1] com.harmeetsingh13.actors.HelloWorldActor | |
| [2] com.harmeetsingh13.actors.HelloWorldPoolActor |
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
| All exercises are attempted on https://coderpad.io |
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 func = (a: Int) => a + 1 | |
| def funcd(a: Int) = a + 1 |
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
| scala> val func = (a: Int) => a + 1 | |
| func: Int => Int = $$Lambda$1030/1250816994@3d98d138 | |
| scala> def funcd(a: Int) = a + 1 | |
| funcd: (a: Int)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
| scala> List(1, 2, 3, 4, 5).map(func) | |
| res0: List[Int] = List(2, 3, 4, 5, 6) | |
| scala> List(1, 2, 3, 4, 5).map(funcd) | |
| res1: List[Int] = List(2, 3, 4, 5, 6) |
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
| scala> val inc = funcd | |
| <console>:12: error: missing argument list for method funcd | |
| Unapplied methods are only converted to functions when a function type is expected. | |
| You can make this conversion explicit by writing `funcd _` or `funcd(_)` instead of `funcd`. | |
| val inc = funcd | |
| ^ |
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
| scala> val inc = funcd _ | |
| inc: Int => Int = $$Lambda$1043/1332208607@56681eaf |
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
| object Test extends App { | |
| val func = (a: Int) => a + 1 | |
| def funcd(a: Int) = a + 1 | |
| val inc = funcd _ | |
| List(1, 2, 3, 4, 5).map(func) | |
| List(1, 2, 3, 4, 5).map(funcd) | |
| } |
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
| /* | |
| Translation 2: | |
| def funcd(a: Int): Int = a.+(1); | |
| private[this] val inc: Int => Int = { | |
| ((a: Int) => Test.this.funcd(a)) | |
| }; | |
| scala.collection.immutable.List.apply[Int](1, 2, 3, 4, 5).map[Int, List[Int]](Test.this.func)(immutable.this.List.canBuildFrom[Int]); | |
| scala.collection.immutable.List.apply[Int](1, 2, 3, 4, 5).map[Int, List[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
| def method1(arg: Int): String = { | |
| s"The method1 passed value is $arg" | |
| } | |
| def method2(arg1: Int, arg2: Int): String = { | |
| s"The method2 passed value sum is ${arg1 + arg2}" | |
| } | |
| def method3(arg1: Int, arg2: Int, arg3: Int): String = { | |
| s"The method3 passed value sum is ${arg1 + arg2 + arg3}" |