Skip to content

Instantly share code, notes, and snippets.

import java.io.IOException;
public class NewInstanceInClass {
public NewInstanceInClass() throws Throwable {
// チェック例外を送出する。
throw new IOException();
}
public static void main(String[] args) {
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
public class NewInstanceInConstructor {
public NewInstanceInConstructor() throws Throwable {
// チェック例外を送出する。
throw new IOException();
}
import java.util.Collection
fun IntRange.fizzBuzz() = this.map {
when (#(it % 3, it % 5)) {
is #(0, 0) -> "fizzbuzz"
is #(0, *) -> "fizz"
is #(*, 0) -> "buzz"
else -> ""
}
}
apply plugin: 'java'
defaultTasks 'build'
sourceSets {
main {
java {
srcDir 'main/java'
}
}
fun main(args: Array<String>) {
println (30.buzzbuzz().toList())
}
fun Int.buzzbuzz(): java.util.Iterator<Int> {
var buzz = #(0, 0)
fun Int.range(size:Int) = (this + 1 .. this + size)
fun buzzer() = {
if (buzz._1 >= this) {
null
@siosio
siosio / gist:2933736
Created June 15, 2012 00:02
なんか違うものになってしまったけど
class Buzz implements Comparable<Buzz> {
private int index
private Buzz(int index) {
this.index = index
}
def static start(int index) {
while (!isBuzz(index)) {index++}
package siosio.validator
import org.codehaus.groovy.grails.validation.AbstractConstraint
import org.springframework.validation.Errors
class NumCharValidator extends AbstractConstraint {
public static final NAME = "number"
private static final String DEFAULT_MESSAGE = "default.invalid.number.message"
package siosio.validator
import grails.validation.ValidationErrors
import org.junit.Test
import org.junit.Before
class NumCharValidatorTest {
NumCharValidator validator
@siosio
siosio / Fuga.groovy
Created July 11, 2012 09:28
クロージャの名前
class Hogehoge {
def cls = {}
static hogefuga = {}
}
cls = {}
def cls2 = {}
def method(Closure c) {
println getDeclaredName(c)
@siosio
siosio / fizzbuzz.sql
Created July 15, 2012 12:23
SQLでfizzbuzz
select case
when mod(seq.col1, 3) = 0 and mod(seq.col1, 5) = 0 then
'fizzbuzz'
when mod(seq.col1, 3) = 0 then
'fizz'
when mod(seq.col1, 5) = 0 then
'buzz'
else
to_char(seq.col1)
end fizzbuzz