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.Option | |
class User(private val firstname: String, private val lastname: String) | |
object User { | |
def unapply(user: User) = Option((user.firstname, user.lastname)) | |
def main(args: Array[String]): Unit = { | |
val user = new User("剛次", "赤石") |
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
public class ArrayList<E> {...} |
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 akka.actor.ActorSystem | |
import akka.actor.Props | |
import akka.actor.Actor | |
import akka.routing.RoundRobinRouter | |
object ActorSample { | |
def main(args: Array[String]): Unit = { | |
val system = ActorSystem("helloSystem") | |
val router = system.actorOf(Props[HelloActor].withRouter(RoundRobinRouter(4))) |
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
scala> val add = {(x:Int, y:Int, z:Int) => x + y + z} | |
add: (Int, Int, Int) => Int = <function3> |
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.Random | |
object PatternMatchConst { | |
def main(args: Array[String]): Unit = { | |
val random = Random.nextBoolean | |
val num = random match { | |
case true => 1 | |
case false => 0 |
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
scala> 1 + 2 | |
res0: Int = 3 | |
scala> 3 - 1 | |
res1: Int = 2 | |
scala> 4 * 2 | |
res2: Int = 8 | |
scala> 6 / 3 |
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
#/bin/sh | |
# commands. | |
SENDMAIL=/usr/lib/sendmail | |
ECHO=/bin/echo | |
GZIP=/bin/gzip | |
CAT=/bin/cat | |
RM=/bin/rm | |
# attachment file info. |
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
object CaseClass { | |
def main(args: Array[String]): Unit = { | |
val domain1 = new Domain3(1, "富樫") | |
val domain2 = new Domain3(1, "富樫") | |
println("==:", domain1 == domain2) | |
println("!=:", domain1 != domain2) | |
val domain3 = new Domain3(2, "虎丸") |
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 java.io.File | |
object IfTest1 { | |
def main(args: Array[String]): Unit = { | |
var filename = "config.txt" | |
if (!args.isEmpty) | |
filename = args(0) |
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
object Option1 { | |
def main(args: Array[String]): Unit = { | |
val map = Map(1 -> "Moses", 2 -> "Lucas", 3 -> "Henderson") | |
def check(o: Option[String]) { | |
o match { | |
case Some(s) => println(s) | |
case None => println("Not exist.") | |
} |
NewerOlder