Kotlin for android developers

1. Introduction

1.1 What is Kotlin

  • Kotlin is very intuitive and easy to learn for Java developers
  • We have total integration with our dialy IDE for free
  • It's more expressive
  • It's safer
  • It's functional
  • It makes use of extension functions
  • It's highly interoperable

1.2What do we get with Kotlin

  • Expresiveness
  • Null Safety
    ...

2. Getting ready

3. Creating a new project

18 Collections and functional

18.1 Aggregate operations

any: return true if at least one element matches the given predicate
all: return true if all the elements match the given predicate
count: return the number of elements matching the given predicate
fold: accumulates the value starting with an initial value and applying an operation from the first to the last element in collection
foldRight: same as fold,but it goes from the last to element to first
forEach: performs the given operation to each element.
forEachIndexed: same as forEach, though we also get the index of the element
max:returns the largest element or null if there no elements
maxBy: return the first element yielding the largest value of the given function or null if there are no elements.
min: returns the smallest element or null if there are no elements
minBy: returns the first element yielding the smallest value of the given function or null if there are no elements
none: return true if there no elements match the given predicate
reduce: same as fold,but it does't use an initial value.It accumulates the value applying an operation from the first to the last element in a collection
reduceRight: same as reduce,but it goes from the last element to first
sumBy: returns the sum of all values produced by the transform function from the elements in the collection

18.2 filtering operation

drop: returns a list containing all elements except first n elements
dropWhile: returns a list containing all elements except first elements that satisfy the given predicate.
dropLastWhile: returns a list containing all elements excepting the last that satisfy the given predicate.
filter: returns a list containing all elements matching the given predicate
filterNot: returns a list containing all elements not matching the given predicate
filterNotNull returns a list containing all elements that are not null
silce: returns a list containing elements at specified indices
???

18.3 Mapping operations

你可能感兴趣的:(Kotlin for android developers)