View annotated-lambda.kt
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() | |
} |
View function-declaration-error-when-compiling-with-kotlin-12.kt
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 class SomeAdapter(val friends: SomeAdapterProvider, val listener: OnItemClickedListener) : RecyclerView.Adapter<SomeAdapter.ViewHolder>() { | |
trait OnItemClickedListener { | |
fun onItemClicked(f: Friendship) | |
} | |
private inner class ViewHolder(v: View) : RecyclerView.ViewHolder(v), View.OnClickListener { | |
override fun onClick(v: View) { | |
listener.onItemClicked(somethings[getPosition()]) | |
} |
View ratio.kt
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 Ratio(num : Int, denom : Int) { | |
val numerator: Int | |
val denominator: Int | |
{ | |
val theGcd = gcd(num, denom) | |
numerator = num / theGcd | |
denominator = denom / theGcd | |
} | |
} |
View getInstance.md
Calling a class object member from Java:
public class Engine private() {
class object {
public fun getInstance(): Engine = Engine()
}
}
View kotlin2014-15.md
Kotlin (Programming Language)
Kotlin is a modern statically typed programming language targeting the Java and JavaScript platforms. It is conceived as a "modern language for industry", keeping a balance between flexibility and readability, expressiveness and safety.
Project Overview
A modern programming language is much more than a grammar. Principal susystems of Kotlin include
- Compiler front-end
- Lexer/Parser translates text into a syntax tree, reports syntax errors
View Variance.kt
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
// Why do we need variance | |
// Invariant class List, just like in Java | |
class List<T> { /* normal list */ } | |
fun printContents(list: List<Any>) { | |
for (item in list) { | |
println(item) | |
} | |
} |
View gist:9188294
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
Red node isn't marked as red: Red node isn't marked as red | |
java.lang.AssertionError: Red node isn't marked as red | |
at com.intellij.vcs.log.data.VcsLogJoiner$RedGreenSorter.markRealRedNode(VcsLogJoiner.java:175) | |
at com.intellij.vcs.log.data.VcsLogJoiner$RedGreenSorter.getFirstSaveIndex(VcsLogJoiner.java:191) | |
at com.intellij.vcs.log.data.VcsLogJoiner$RedGreenSorter.access$300(VcsLogJoiner.java:161) | |
at com.intellij.vcs.log.data.VcsLogJoiner.getRedCommitsAndSavedRedIndex(VcsLogJoiner.java:154) | |
at com.intellij.vcs.log.data.VcsLogJoiner.addCommits(VcsLogJoiner.java:53) | |
at com.intellij.vcs.log.data.VcsLogDataHolder.smartRefresh(VcsLogDataHolder.java:385) | |
at com.intellij.vcs.log.data.VcsLogDataHolder.access$2400(VcsLogDataHolder.java:88) | |
at com.intellij.vcs.log.data.VcsLogDataHolder$12.consume(VcsLogDataHolder.java:668) |
View gist:9188277
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
Ref should exist for this node. Hash: 603812 | |
java.lang.Throwable | |
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:113) | |
at com.intellij.vcs.log.graph.mutable.GraphBuilder.createBranch(GraphBuilder.java:123) | |
at com.intellij.vcs.log.graph.mutable.GraphBuilder.addCurrentCommitAndFinishRow(GraphBuilder.java:107) | |
at com.intellij.vcs.log.graph.mutable.GraphBuilder.append(GraphBuilder.java:165) | |
at com.intellij.vcs.log.graph.mutable.GraphBuilder.runBuild(GraphBuilder.java:198) | |
at com.intellij.vcs.log.graph.mutable.GraphBuilder.build(GraphBuilder.java:29) | |
at com.intellij.vcs.log.data.DataPack.build(DataPack.java:43) | |
at com.intellij.vcs.log.data.VcsLogDataHolder.smartRefresh(VcsLogDataHolder.java:404) |
View sample.kt
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 Bar { | |
fun invoke(x: Int): Int = x | |
} | |
class Foo { | |
val get: Bar = Bar() | |
} | |
fun foo () { |
NewerOlder