-
-
Save deinspanjer/8a677933f5b85135b05a597c7fbc298c to your computer and use it in GitHub Desktop.
This file contains 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
package com.jsonlogic | |
import com.google.gson.JsonArray | |
import com.google.gson.JsonElement | |
fun main(args: Array<String>) { | |
val arr: JsonArray = JsonArray() | |
arr.add(1) | |
arr.add(2) | |
arr.add(3) | |
// I can get this far which seems to be the right track, sorta.. | |
fun nummer(el: JsonElement): String { return "Num: ${el.asString}" } | |
println(arr.map(::nummer)) | |
// But I need to support this method: | |
fun JsonArray.getMethod(methodName: String): Function<Any> { | |
return when (methodName) { | |
"map" -> this::map | |
} | |
} | |
println(arr.getMethod("map").call { return "Num: ${it.asString}" }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment