- Ubuntu 18.04 64bit
- opam 2.0.0
- ocaml 4.06.1 (最新は4.07だが、batteriesが未対応なので4.06で作る)
- dune 1.2.1
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 extends App{ | |
trait Creatable[T] { | |
def create(): T | |
} | |
class Cat(val name: String) | |
// 自作の型への適用 | |
implicit object Cat extends Creatable[Cat] { | |
def create(): Cat = new Cat("taro") |
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 extends App{ | |
trait Creatable[T] { | |
def create(): T | |
} | |
class Cat(val name: String) | |
// 自作の型への適用 | |
implicit object Cat extends Creatable[Cat] { | |
def create() = new Cat("taro") |
- mimaの以下のtree https://github.com/typesafehub/migration-manager/tree/03e63a79c94eebce1b6f3cc で sbt コンソールで
project reporter
としてから実行
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
class A() { | |
init { | |
val s: String = getStr() | |
println("${s.length}") // java.lang.NullPointerException | |
} | |
fun getStr(): String { | |
return str | |
} | |
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
# coding: utf-8 | |
def foo(array_or_hash) | |
if array_or_hash.responds_to?(:values) | |
# Hashっぽい | |
array_or_hash.values.join(", ") | |
else | |
# きっとArray | |
array_or_hash.join(", ") | |
end |
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
package com.example | |
case class Foo[M[_], A](step: M[Foo.Step[A, Foo[M, A]]]) | |
object Foo { | |
class Step[A, S] | |
object Done { | |
def unapply[A, S](a: Step[A, S]): Boolean = true | |
} | |
} |
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
package controllers | |
import play.api.mvc._ | |
object Application extends Controller { | |
def upload = Action(parse.multipartFormData) { | |
request => | |
if (request.body.files.isEmpty) BadRequest("Invalid file!") | |
else if (request.body.asFormUrlEncoded.isEmpty) BadRequest("Invalid data!") | |
else Ok("Everything is okay!") |
NewerOlder