Skip to content

Instantly share code, notes, and snippets.

View skydoves's full-sized avatar
💡
Practice is the only shortcut

Jaewoong Eum skydoves

💡
Practice is the only shortcut
View GitHub Profile
@skydoves
skydoves / 17_ExtensionFunctionDecompiled.java
Created February 17, 2026 01:14
Decompiled Extension Function - Static Method
public final class ExtensionFunctionKt {
public static String addExclamation(String receiver) {
return receiver + "!";
}
}
@skydoves
skydoves / 16_ExtensionFunction.kt
Created February 17, 2026 01:14
Kotlin Extension Function
fun String.addExclamation(): String {
return this + "!"
}
fun main() {
val result = "skydoves".addExclamation()
println(result) // Output: skydoves!
}
@skydoves
skydoves / 15_InlineFunctionDecompiled.java
Created February 17, 2026 01:14
Decompiled Inline Function - Zero Allocation
int result = 10 * 2;
@skydoves
skydoves / 14_InlineFunction.kt
Created February 17, 2026 01:14
Kotlin Inline Function
inline fun inlineHigherOrderExample(operation: (Int) -> Int): Int {
return operation(10)
}
val result = inlineHigherOrderExample { it * 2 }
@skydoves
skydoves / 13_LambdaCallDecompiled.java
Created February 17, 2026 01:14
Decompiled Lambda - Anonymous Class Generation
Function1<Integer, Integer> lambda = new Function1<Integer, Integer>() {
@Override
public Integer invoke(Integer it) {
return it * 2;
}
};
int result = higherOrderExample(lambda);
@skydoves
skydoves / 12_LambdaCall.kt
Created February 17, 2026 01:14
Kotlin Lambda Call
val result = higherOrderExample { it * 2 }
@skydoves
skydoves / 11_HigherOrderFunctionDecompiled.java
Created February 17, 2026 01:14
Decompiled Higher-Order Function - Function1 Interface
int higherOrderExample(Function1<Integer, Integer> operation) {
return operation.invoke(10);
}
@skydoves
skydoves / 10_HigherOrderFunction.kt
Created February 17, 2026 01:14
Kotlin Higher-Order Function
fun higherOrderExample(operation: (Int) -> Int): Int {
return operation(10)
}
@skydoves
skydoves / 09_ValueClassBoxing.kt
Created February 17, 2026 01:14
Value Class Boxing Scenarios in Kotlin
val id1: Any = UserId("abc") // Stored as Any, forces boxing
val id2: UserId? = UserId("def") // Nullable type can force boxing
val listOfIds = listOf(UserId("1")) // Generic collection, forces boxing
@skydoves
skydoves / 08_ValueClassDecompiled.java
Created February 17, 2026 01:14
Decompiled Value Class - Java Bytecode
public final class IdKt {
// The function takes the PRIMITIVE type directly
public static final void processId(String userId) {
String var1 = "Processing user with ID: " + userId;
System.out.println(var1);
}
public static final void main() {
// No UserId object allocated
String myId = UserId.constructor_impl("user-123");