[F] Fix long casting

This commit is contained in:
Azalea
2024-03-28 01:56:23 -04:00
parent 50ae04bb4e
commit 1cdbed51cd
2 changed files with 9 additions and 3 deletions

View File

@@ -115,6 +115,12 @@ catch (e: Exception) { null } }
fun Long.toHex(len: Int = 16): Str = "0x${this.toString(len).padStart(len, '0').uppercase()}"
fun Map<String, Any>.toUrl() = entries.joinToString("&") { (k, v) -> "$k=$v" }
fun Any.long() = when (this) {
is Number -> toLong()
is String -> toLong()
else -> 400 - "Invalid number: $this"
}
// Collections
operator fun <K, V> Map<K, V>.plus(map: Map<K, V>) =
(if (this is MutableMap) this else toMutableMap()).apply { putAll(map) }