Created
November 30, 2015 19:55
-
-
Save Jire/63da3cf482bb9f5d4749 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val TYPE_TO_BYTES = mapOf(Boolean::class.java to 1, Byte::class.java to 1, | |
Short::class.java to 2, Int::class.java to 4, Long::class.java to 8, | |
Float::class.java to 4, Double::class.java to 8) | |
inline fun <reified T: Any> read(address: Long): T { | |
val type = T::class | |
if (Int::class.java == type.java) | |
println("Nice! :)") | |
else if (Int::class == type) // would be nicer if this was possible | |
println("Nicer!") | |
if (!TYPE_TO_BYTES.contains(type.java)) | |
println("Why not!?!?! ${type.java}") | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment