Skip to content

Instantly share code, notes, and snippets.

View Hoegy's full-sized avatar

John Hoegy Hoegy

  • Charlotte, NC, USA
View GitHub Profile
Right now I am: cruising the boulevard with my Chevrolet Bel Air
open class Vehicle {
var make = ""
var model = ""
}
interface LandVehicle
fun <T> T.cruiseTheBoulevard(): String where T: Vehicle, T: LandVehicle {
return "cruising the boulevard with my $make $model"
}
Right now I am: cruising the boulevard with my Chevrolet Bel Air
Right now I am: cruising the boulevard with my SpaceX Starship
open class Vehicle {
var make = ""
var model = ""
}
interface LandVehicle
fun Vehicle.cruiseTheBoulevard(): String {
return "cruising the boulevard with my $make $model"
}
fun Vehicle.cruiseTheBoulevard(): String {
return "cruising the boulevard with my ${getMakeAndModel()}"
}
@Hoegy
Hoegy / extension_function_example1.kt
Last active May 22, 2021 19:56
extension_function_example2.kt
interface LandVehicle
fun <T> T.cruiseTheBoulevard(): String where T: Vehicle, T: LandVehicle {
return "cruising the boulevard with my ${getMakeAndModel()}"
}
@Hoegy
Hoegy / extension_function_example.kt
Created May 22, 2021 18:24
extension function example
fun Vehicle.cruiseTheBoulevard(): String
@Hoegy
Hoegy / with_mutex_vs_no_mutex_table.csv
Created December 27, 2020 18:54
With Mutex vs. No Mutex table
Test Run With Mutex No Mutex
1 10000 10000
2 10000 9094
3 10000 8895
4 10000 10000
5 10000 10000
6 10000 9570
7 10000 9137
8 10000 9591
9 10000 10000
@Hoegy
Hoegy / mutexForCoroutines.kt
Created December 27, 2020 18:38
Mutex for coroutines
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.Default
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
private val mutex = Mutex() // our hero ;-)
private var counterWithMutex = 0
private var counterNoMutex = 0
suspend fun main( ) {