Skip to content

Instantly share code, notes, and snippets.

@exallium

exallium/datak.kt

Last active Aug 29, 2015
Embed
What would you like to do?
kotlinvsxtend
data class MyValueObject(val a: Int, val b: String)
@Data class Person {
String firstName
String lastName
}
fun MutableList<Int>.swap(x: Int, y: Int) {
val tmp = this[x] // 'this' corresponds to the list
this[x] = this[y]
this[y] = tmp
}
class MyClass {
def doSomething(Object obj) {
// do something with obj
}
def extensionCall(Object obj) {
obj.doSomething() // calls this.doSomething(obj)
}
}
public fun myFunction(a: Int): Int {
return a + 1;
}
public fun myFunction(a: Int): Int = a + 1
def Integer myFunction(Integer a) {
a + 1
}
ol {
li("List Item 1")
li("List Item 2")
}
fieldset() {
label("Text Input")
input(inputType="text", value="Text")
}
p {
+ "Some text"
+ "Some more text"
}
fun reformat(
str: String,
normalizeCase: Boolean = true,
upperCaseFirstLetter: Boolean = true,
divideByCamelHumps: Boolean = false,
wordSeparator: Character = ' ') {
//...
}
def someHTML(List<Paragraph> paragraphs) '''
<html>
<body>
«FOR p : paragraphs BEFORE '<div>' SEPARATOR '</div><div>' AFTER '</div>'»
«IF p.headLine != null»
<h1>«p.headline»</h1>
«ENDIF»
<p>
«p.text»
</p>
«ENDFOR»
</body>
</html>
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.