Hey, during my work I realized I’m creating a lot ...
# announcements
o
Hey, during my work I realized I’m creating a lot of functions made for chain calls
Copy code
fun categoryId(vararg ids: Int): Filter {
  params.put("categoryId", listOf(ids))
  return this
}
I would like to provide a bunch of this-a-like methods to other developers to make their work easier. Generally for Java developers, but writing
return this
in each method feels messy. I thought a moment about solution and this came to me:
Copy code
fun categoryId(vararg ids: Int): this = params.put("categoryId", listOf(ids))
Here I propose this as return type, in terms of functionality it will be equal to first piece of code. This won’t be very useful within Kotlin only projects (apply) but for those writing in Kotlin for Java developers it might be useful, also this will reduce some code for builders. What do you think ? Does it feels like good idea ?