Dave Leeds
08/04/2016, 4:35 PM@RequestMapping(value = "/something/somewhere", method = GET)
@ResponseBody
public String doStuff() {
return "";
}
Translating this to Kotlin, I get this:
@RequestMapping(value = "/something/somewhere", method = GET)
@ResponseBody
fun doStuff(): String {
return ""
}
That gives me this compile error: Type mismatch: inferred type is RequestMethod but Array<RequestMethod> was expected
.
Of course, I can fix that by wrapping the RequestMethod with arrayOf()
, like this:
@RequestMapping(value = "/something/somewhere", method = arrayOf(GET))
@ResponseBody
fun doStuff(): String {
return ""
}
That works, but I’d like to understand — why do you have to specify the method
as an array in Kotlin but not in Java?