Kotlin features

  1. time
  2. streams
  3. try-with-resources
  4. Function expansion, to the types, classes or interfaces new method
  5. null safe
  6. It does not require new, type declaration suffixes
  7. There getters and setters automatically converted comprehensive property types, such as automatically replace getDay () for the day, looks like a field, but in fact the concept of integration of property-getter and setter
  8. Function expression lambdas, it: a single parameter name implicit
  9. Higher-order function, the function when the function returns a function or parameter of formula
  10. Extended function expression = function expressions Spread Function + + higher order functions
fun SQLiteDatabase.inTransaction(func: (SQLiteDatabase) -> Unit) {
 beginTransaction()
 try {
   func(this)
   setTransactionSuccessful()
 } finally {
   endTransaction()
 }
}

db.inTransaction {
 it.db.delete("users", "first_name = ?", arrayOf("Jake"))
}
  1. in-line function
  2. Anko Definitions UI

Guess you like

Origin www.cnblogs.com/lshare/p/11334513.html
Recommended