- Kotlin Blueprints
- Ashish Belagali Hardik Trivedi Akshay Chordiya
- 94字
- 2021-07-02 21:50:19
Extension functions
The common and utility functions are grouped in a file named Extension.kt (you can specify any name you want). It contains top-level functions that can be used anywhere in the project.
Complete the Extension.kt file:
/**
* Builds the insert query for the specified message
*/
fun insertQuery(m: Message): Messages.(UpdateBuilder<*>) -> Unit =
{
if (m.id != null) it[id] = m.id
it[content] = m.content
it[location] = m.location
}
/**
* Create the message object from Result row
* @return message
*/
fun ResultRow.getMessage() =
Message(this[Messages.content], this[Messages.location],
this[Messages.id])
// Other extension functions
推薦閱讀