Skip to content

Instantly share code, notes, and snippets.

@exallium
Last active August 29, 2015 14:21
Show Gist options
  • Save exallium/181c6561014e1daaef4a to your computer and use it in GitHub Desktop.
Save exallium/181c6561014e1daaef4a to your computer and use it in GitHub Desktop.
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