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 Main { | |
import java.net._ | |
import java.util.Date | |
case class Access( | |
ipAddress: InetAddress, | |
ident: String, | |
user: String, | |
time: Date, |
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
// obj ::= "{" [members] "}". | |
// arr ::= "[" [values] "]". | |
// value ::= obj | arr | stringLiteral | floatingPointNumber | "null" | "true" | "false". | |
// values ::= value { "," value }. | |
// members ::= member { "," member }. | |
// member ::= stringLiteral ":" value. | |
object Main { | |
import util.parsing.combinator._ |
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 Main { | |
import java.net._ | |
import java.util.Date | |
case class Access( | |
ipAddress: InetAddress, | |
ident: String, | |
user: String, | |
time: Date, |
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 unfiltered.request._ | |
import unfiltered.response._ | |
// Planify使ってpartial functionでintentの中だけ書く | |
val echo = unfiltered.filter.Planify { | |
case Path(Seg(p :: Nil)) => ResponseString(p) | |
} | |
unfiltered.jetty.Http.anylocal.filter(echo).run() | |
// Planを継承したobjectを作ってintentを定義する |
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 Example1 { | |
public static class Person { | |
public static final String DEFAULT_NAME = "anonymous"; | |
private String name = DEFAULT_NAME; | |
public Person() { | |
} |
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 Person { | |
val DEFAULT_NAME = "anonymous" | |
} | |
class Person(var name: String) { | |
def this() { | |
this(Person.DEFAULT_NAME) | |
} | |
def canWriteCode = false | |
} |
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.util.Arrays; | |
import java.util.Comparator; | |
public class Example2 { | |
public static void main(String[] args) { | |
Integer[] arr = new Integer[]{1, 5, 3, 2, 4}; | |
Arrays.sort(arr, new Comparator<Integer>() { |
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
val arr = Array(1,5,3,2,4) | |
val res = arr.sortWith { (i1,i2) => i1 < i2 } | |
res foreach println | |
val compare = (i1:Int, i2:Int) => i1 < i2 | |
val res = arr.sortWith(compare) | |
def compare(i1:Int, i2:Int) = i1 < i2 | |
val res = arr sortWith compare _ |
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
type HasName = { def name: String } | |
trait CanSpeak { this: HasName => | |
def introduce = println("Hi, I'm " + name + ".") | |
} | |
trait CanRun { this: HasName => | |
def run = println(name + " start running!") | |
} |
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
// ----------------- | |
// #daimonscala 22 ハンズオン | |
// ----------------- | |
// 1. ListからMapをつくろう | |
val list = List("Scala", "http://scala-lang.org", "Java", "http://java.net/", "Haskell", "http://haskell.org/") | |
// Map(Scala -> http://scala-lang.org, Java -> http://java.net/, Haskell -> http://haskell.org/) |