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 Maybe < BasicObject | |
| def initialize(obj) | |
| @just = obj | |
| end | |
| # for debug | |
| def inspect | |
| "#<Maybe: just(#{@just.inspect})>" | |
| end |
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
| module Kernel | |
| def maybe | |
| block_given? && yield | |
| rescue NoMethodError | |
| end | |
| end |
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
| import scala.swing._ | |
| object Hello extends SimpleSwingApplication { | |
| def top = new MainFrame { | |
| title = "Hello world" | |
| contents = new Label("Hello world") | |
| } | |
| } |
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
| type Database = Map[String, Any] | |
| case class Item[+A](name: String) { | |
| def get(d: Database) = d(name).asInstanceOf[A] | |
| } | |
| implicit class DB(val d: Database) extends AnyVal { | |
| def get[A](n: Item[A]): A = n.get(d) | |
| } |
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 fail(i: Int): Either[String,Int] = Left(s"error occored from $i") | |
| // 成功する処理 | |
| def success(i: Int): Either[String,Int] = Right(i + 1) | |
| println("すべて成功する (e is 5)") | |
| val result0 = for { | |
| a <- success(0).right | |
| b <- success(a).right |
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 xml = | |
| <body> | |
| <item> | |
| <name>aaaaa</name> | |
| <url>httpppppp</url> | |
| <description>cccc</description> | |
| </item> | |
| <item> | |
| <name>aaaaa</name> | |
| <url>httpppppp</url> |
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
| import scala.Predef.; | |
| import scala.Serializable; | |
| import scala.collection.immutable.Range.Inclusive; | |
| import scala.runtime.AbstractFunction1; | |
| import scala.runtime.BoxedUnit; | |
| import scala.runtime.RichInt.; | |
| public final class Hello$ | |
| { | |
| public static final MODULE$; |
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
| package models | |
| import scalikejdbc._ | |
| import skinny.orm.{SkinnyCRUDMapper, SkinnyRecord} | |
| case class Example( id: Long, name: Option[String] = None ) extends SkinnyRecord[Example] { | |
| def skinnyCRUDMapper = Example | |
| } | |
| object Example extends SkinnyCRUDMapper[Example] { |
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
| package mystate | |
| import scalaz._ | |
| import Scalaz._ | |
| case class RandGen(seed: Long) { | |
| def nextInt: (RandGen, Int) = { | |
| val newSeed = (seed * 0x5DEECE66DL + 0xBL) & 0xFFFFFFFFFFFFL | |
| val nextGen = RandGen(newSeed) | |
| val n = (newSeed >>> 16).toInt |
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
| kkismd 31 minutes前 | |
| コードを直しながらsbt shellの中でtestを繰り返し実行していると、そのうち | |
| java.lang.OutOfMemoryError: PermGen space | |
| が出て落ちることが多いのですが、これはクラスローダーまわりになにかリークが起こってるんでしょうか? | |
| xuwei-k 30 minutes前 | |
| はい | |
| (もしメモリの設定を変えてなかったら)設定を増やしましょう | |
| あとは、コンパイルじゃなくtestのほうが原因なら、testは必ずforkして実行するとか |