This file contains hidden or 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 hidden or 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()]) | |
} |
This file contains hidden or 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 | |
} | |
} |
Calling a class object member from Java:
public class Engine private() {
class object {
public fun getInstance(): Engine = Engine()
}
}
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.
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
This file contains hidden or 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) | |
} | |
} |
This file contains hidden or 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) |
This file contains hidden or 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) |
This file contains hidden or 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