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
fun Int.divides(d: Int) = this % d == 0 | |
fun fizzbuzz(n: Int) = when { | |
n divides 15 -> "fizzbuzz" | |
n divides 3 -> "fizz" | |
n divides 5 -> "buzz" | |
else -> "$n" | |
} | |
fun result(max: Int) = (0..max) map { n -> fizzbuzz(n) } |
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
annotation class A | |
fun main(args: Array<String>) { | |
val f = @A {} | |
f.javaClass.methods.filter { it.name == "invoke" && it.parameterTypes.isEmpty() }.forEach { | |
it.annotations.forEach(::println) | |
println(it) | |
println() | |
} |
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
fun main(args: Array<String>) { | |
val array = Class.forName("java.util.Collection")?.getInterfaces()!! | |
for (c in array) { | |
println(c) | |
c!!.accept(ClassVisitor()) | |
} | |
} | |
class ClassVisitor |
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
interface Comparator<T> { | |
boolean lt(T left, T right); | |
} | |
static Object NULL = new Object(); | |
static class LtInf implements Comparator<Object> { | |
@Override | |
public boolean lt(Object left, Object right) { |
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
ModuleConfiguration moduleConfiguration = new ModuleConfiguration() { | |
@Override | |
public void addDefaultImports(@NotNull Collection<JetImportDirective> directives) { | |
for (ImportPath defaultJetImport : DefaultModuleConfiguration.DEFAULT_JET_IMPORTS) { | |
directives.add(JetPsiFactory.createImportDirective(project, defaultJetImport)); | |
} | |
} | |
@Override | |
public void extendNamespaceScope( |
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(val b : B, val c : C) {...} | |
fun test() { | |
val a = A( | |
b = B(), | |
c = C() | |
) | |
} |
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 static void compareNamespaces(@NotNull NamespaceDescriptor nsa, @NotNull NamespaceDescriptor nsb, boolean includeObject, | |
@NotNull File txtFile) { | |
String serialized = new NamespaceComparator(includeObject).doCompareNamespaces(nsa, nsb); | |
try { | |
if (!txtFile.exists()) { | |
FileUtil.writeToFile(txtFile, serialized); | |
Assert.fail("Expected data file did not exist. Generating: " + txtFile); | |
} | |
String expected = FileUtil.loadFile(txtFile); |
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 hhh.csp | |
import org.junit.* | |
import org.junit.rules.ExpectedException | |
import junit.framework.TestCase | |
import junit.framework.TestSuite | |
public class IntervalTest(name :String) : TestCase(name) { | |
fun testIntervalPlus() { |
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
fun main(args : Array<String>) { | |
println("Hello, GitHub!") | |
} |
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
fun assert(i : Int) = println(i) | |
fun abstract(i : Int) = println(i) | |
fun boolean(i : Int) = println(i) | |
fun `break`(i : Int) = println(i) | |
fun byte(i : Int) = println(i) | |
fun case(i : Int) = println(i) | |
fun catch(i : Int) = println(i) | |
fun char(i : Int) = println(i) | |
fun `class`(i : Int) = println(i) | |
fun const(i : Int) = println(i) |