Hi all - got a question. In Java, I can have a Sp...
# spring
d
Hi all - got a question. In Java, I can have a Spring controller method that looks like this:
Copy code
@RequestMapping(value = "/something/somewhere", method = GET)
    @ResponseBody
    public String doStuff() {
        return "";
    }
Translating this to Kotlin, I get this:
Copy code
@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:
Copy code
@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?