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 Ads { | |
fun display() { | |
Log.i("Ads", "The view was beautifully decorated with several ads") | |
} | |
} |
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 Analytics { | |
fun analyze() { | |
Log.i("Analytics", "Your private data was obtained anonymously") | |
} | |
} |
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 Drive { | |
fun sync() { | |
Log.i("Drive", "The drive has been synchronized") | |
} | |
} |
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 ListItem<ItemType>(val item: ItemType, val printer: AbstractItemPrinter<ItemType>) | |
abstract class AbstractItemPrinter<ItemType> { | |
abstract fun print(item: ItemType) | |
@Suppress("UNCHECKED_CAST") // It is a safe cast... when used properly ;) | |
fun delegatePrint(item: Any?) { | |
print(item as ItemType) | |
} | |
} |
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 Cat { | |
fun meow() { | |
println("Meow?") | |
} | |
} | |
class ThisClass | |
fun classCheckExample() { | |
val listOfAny = listOf<Any>(ApplePie(), Cheesecake(), Coffee(), Cat(), ThisClass()) |
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 Consumable { | |
fun consume() | |
} | |
class ApplePie : Consumable { | |
override fun consume() { | |
println("Yummy apple pie!") | |
} | |
} |
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 ApplePie | |
class Cheesecake | |
class Coffee | |
fun listOfAnyExample() { | |
val listOfAny = listOf<Any>(ApplePie(), Cheesecake(), Coffee()) | |
listOfAny.forEach { println("I am ${it.javaClass.simpleName}.") } | |
} |
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
const c = false && "true" // === false && "false" | |
const h = "true" && false // === "false" && false | |
const a = true && "true" | |
const o = "true" && true | |
const t = true && "false" | |
const i = "false" && true | |
const k = [c, h, a, o, t, i] | |
for(let result of k) | |
console.log(`${typeof result} ${result}`) |