Any.hashCode() and Any?.hasCodeOrDefault(Int) added to standard library
This commit is contained in:
@@ -47,3 +47,9 @@ public inline fun <T> callable(action: ()-> T): Callable<T> {
|
|||||||
public override fun call() = action()
|
public override fun call() = action()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A helper method for calling hashCode() on Kotlin objects
|
||||||
|
* TODO remove when Any supports equals() and hashCode()
|
||||||
|
*/
|
||||||
|
public inline fun Any.hashCode(): Int = (this as java.lang.Object).hashCode()
|
||||||
|
|||||||
@@ -181,3 +181,7 @@ public inline fun <in T> T?.toSortedList(transform: fun(T) : java.lang.Comparabl
|
|||||||
return answer
|
return answer
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/** Returns a hash code on an existing object, or default value otherwise */
|
||||||
|
public inline fun Any?.hashCodeOrDefault(default: Int): Int = if (this == null) default else this.hashCode()
|
||||||
|
|||||||
Reference in New Issue
Block a user