https://kotlinlang.org logo
Title
p

Pardeep Sharma

04/05/2023, 7:12 PM
Can anyone enlightens me about below shortcut structure in Kotlin: fun letsSearch(search: SearchModel.() -> SearchModel) { //how to utilize search param here.. }
j

Jan Lund

04/05/2023, 7:26 PM
Perhaps the information about type safe builders can enlighten you https://kotlinlang.org/docs/type-safe-builders.html#how-it-works
m

Maciej Pigulski

04/05/2023, 7:43 PM
SearchModel is passed into the lambda as ‘this’ and lambda expects it will return a SearchModel instance, so this basically looks like a function to update SearchModel, probably via copy
Link from Jan explains it on an example