Last active
August 29, 2015 14:21
-
-
Save exallium/181c6561014e1daaef4a to your computer and use it in GitHub Desktop.
kotlinvsxtend
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
data class MyValueObject(val a: Int, val b: String) |
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
@Data class Person { | |
String firstName | |
String lastName | |
} |
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
fun MutableList<Int>.swap(x: Int, y: Int) { | |
val tmp = this[x] // 'this' corresponds to the list | |
this[x] = this[y] | |
this[y] = tmp | |
} |
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 MyClass { | |
def doSomething(Object obj) { | |
// do something with obj | |
} | |
def extensionCall(Object obj) { | |
obj.doSomething() // calls this.doSomething(obj) | |
} | |
} |
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 fun myFunction(a: Int): Int { | |
return a + 1; | |
} | |
public fun myFunction(a: Int): Int = a + 1 |
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
def Integer myFunction(Integer a) { | |
a + 1 | |
} |
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
ol { | |
li("List Item 1") | |
li("List Item 2") | |
} | |
fieldset() { | |
label("Text Input") | |
input(inputType="text", value="Text") | |
} | |
p { | |
+ "Some text" | |
+ "Some more text" | |
} |
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
fun reformat( | |
str: String, | |
normalizeCase: Boolean = true, | |
upperCaseFirstLetter: Boolean = true, | |
divideByCamelHumps: Boolean = false, | |
wordSeparator: Character = ' ') { | |
//... | |
} |
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
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