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
struct Person { | |
@CamelCase var name: String | |
} | |
@propertyWrapper | |
struct CamelCase { | |
var wrappedValue: String { | |
didSet { wrappedValue = wrappedValue.camelCase } | |
} | |
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 Person { | |
var schoolName by CamelCased() | |
} | |
class CamelCased { | |
private var value: String = "" | |
operator fun getValue(thisRef: Any?, property: KProperty<*>): String { | |
return value |
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
interface APIService { | |
// get all Star War films | |
@GET("/films") | |
fun getAllFilms(): Single<FilmListResponse> | |
// search for Starships | |
@GET("/starships") | |
fun getStarships(@Query("search") name: String): Single<StarshipListResponse> | |
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
//Kotlin | |
fun sample() { | |
val array = arrayOf(1, 2, 3, 4, 5) | |
array.forEachIndexed { index, item -> | |
print(item) | |
} | |
} | |
//Bytecode | |
public static final void sample() { |
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
//Kotlin | |
fun checkMonsterName() { | |
val list = listOf(Monster("Nergigante"), Monster("Teostra"), Monster("Uragaan")) | |
val array = arrayOf(Monster("Nergigante"), Monster("Teostra"), Monster("Uragaan")) | |
list.forEach { | |
print(it.name) | |
} |
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
//Kotlin | |
class Monster { | |
var level = 10 | |
fun getName(hp: Int): String { | |
return when { | |
hp == 2 -> "Nergigante" | |
hp + 3 > 10 -> "Teostra" | |
hp < 0 -> "Jagras" |
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
//Kotlin | |
class Person { | |
companion object { | |
@JvmField val JVM_FIELD_NAME = "John Doe" | |
const val CONST_NAME = "Josh Doe" | |
} | |
} |
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 Person { | |
companion object { | |
val NAME = "John Doe" | |
} | |
} | |
public final class Person { | |
@NotNull |
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
//Kotlin | |
class Person { | |
companion object { | |
const val NAME = "John Doe" | |
} | |
} | |
//Bytecode | |
public final class Person { | |
@NotNull |
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
//Kotlin | |
"(${input + 2}), ${if(input > 2) { "Hi" } else {"Bye"}}" | |
//Bytecode | |
(new StringBuilder()).append('(').append(input + 2).append("), ").append(input > 2 ? "Hi" : "Bye").toString(); |