Skip to content

Instantly share code, notes, and snippets.

View beyondeye's full-sized avatar

Dario Elyasy beyondeye

View GitHub Profile
@beyondeye
beyondeye / IntArray2d.kt
Created October 28, 2015 08:51
A prototype 2D array implementation
class IntArray2D: Cloneable
{
val xsize:Int
val ysize:Int
val _array:IntArray
constructor(xsize:Int, ysize:Int){
this.xsize=xsize
this.ysize=ysize
_array = IntArray(xsize*ysize)
}
@beyondeye
beyondeye / possible_bug_with_let.kt
Created November 2, 2015 15:54
possible bug with let in kotlin 1.0 beta
fun thisFunctionThrows() {
val a="aa"
a.let {
if(a!="aa") //<----------------
throw IllegalArgumentException()
}
}
fun thisFunctionDoesNotThrows() {
val a="aa"
@beyondeye
beyondeye / firebase_coroutine_integration.kt
Created May 27, 2017 20:32
integration of firebase wth kotlin coroutines
/**
* allow to define callback wrappers that are protected from accidental multiple calls to resume/resumeWithException
* Created by daely on 3/30/2017.
*/
class WrappedContinuation<T>(val c: Continuation<T>) : Continuation<T> {
var isResolved = false
override val context: CoroutineContext
get() = c.context
override fun resume(value: T) {