Skip to content

Instantly share code, notes, and snippets.

interface Func{}
class Function<T>(val f: () -> T) : Func{
fun invoke() = f()
}
class Function1<T>(val f: (value : String) -> T) : Func{
fun invoke(value : String) = f(value)
}
open class A(open val hoge : String)
class B(override val hoge : String) : A(hoge)
fun main(args: Array<String>) {
val a = "a"
val b = "a"
val c = 3
public class Hello {
public static void main(String... args){
if(java.util.Arrays.stream("H,e,l,l,o, W,o,r,l,d,!".split(",")).peek(System.out::print).count() == 0){}
}
}
@JsonCreator
fun create(@JsonProperty age : Int, @JsonProperty name : String) = Person(age, name)
enum class Hoge {
name
}
enum class Hoge {
ordinal
}
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
@RestController
class HelloRestController {
@RequestMapping("/")
import org.hamcrest.Matchers.`is`
import org.junit.Assert.assertThat
import org.junit.experimental.theories.DataPoints
import org.junit.experimental.theories.Theories
import org.junit.experimental.theories.Theory
import org.junit.runner.RunWith
@RunWith(Theories::class)
class Exercise01 {
var fn = function(){ // 無名関数でスコープを形成する
var hoge = "hoge";
return hoge;
};
// これはできるけど
alert(fn())
// これはできない
// alert(hoge);
// FileSample.java
package com.github.yyyank.file.sample;
import java.io.File;
import kotlin.Metadata;
@Metadata(
mv = {1, 1, 2},
bv = {1, 0, 1},
k = 1,

かずひらさんから拝借

XmlSlurper slurper = new groovy.util.XmlSlurper()
String url = "http://yyyank.blogspot.com/feeds/posts/default?max-results=1"
slurper.parse(url)
        .children()
        .grep{it.name() == "entry"}
 .each{println("${it.published.text()}:${it.title.text()}")}