- 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
推薦閱讀
- Learning Scala Programming
- Java程序設計實戰教程
- JavaScript高效圖形編程
- 小創客玩轉圖形化編程
- Effective C#:改善C#代碼的50個有效方法(原書第3版)
- STM32F0實戰:基于HAL庫開發
- Java程序設計:原理與范例
- Advanced Oracle PL/SQL Developer's Guide(Second Edition)
- Mastering JavaScript Design Patterns(Second Edition)
- 51單片機C語言開發教程
- PHP編程基礎與實例教程
- Java程序設計案例教程
- 深入實踐Kotlin元編程
- Mockito Essentials
- Learning Python Data Visualization