mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Replace flatMap with compactMap in README.md
This commit is contained in:
1 parent
bca1fe0d9b
commit
9505ba1606
1 file changed
+3
-3
@@ -5,7 +5,7 @@ GRDB 2 [](ht
|
||||
|
||||
**Latest release**: February 25, 2018 • version 2.9.0 • [CHANGELOG](CHANGELOG.md)
|
||||
|
||||
**Requirements**: iOS 8.0+ / OSX 10.9+ / watchOS 2.0+ • Swift 4.0 / Xcode 9+
|
||||
**Requirements**: iOS 8.0+ / OSX 10.9+ / watchOS 2.0+ • Swift 4+ / Xcode 9+
|
||||
|
||||
| Swift version | GRDB version |
|
||||
| ------------- | ----------------------------------------------------------- |
|
||||
@@ -675,7 +675,7 @@ Both arrays and cursors can iterate over database results. How do you choose one
|
||||
|
||||
If you don't see, or don't care about the difference, use arrays. If you care about memory and performance, use cursors when appropriate.
|
||||
|
||||
**All GRDB cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/2.9/Protocols/Cursor.html) protocol, which looks a lot like standard [lazy sequences](https://developer.apple.com/reference/swift/lazysequenceprotocol) of Swift.** As such, cursors come with many convenience methods: `contains`, `dropFirst`, `dropLast`, `drop(while:)`, `enumerated`, `filter`, `first`, `flatMap`, `forEach`, `joined`, `joined(separator:)`, `max`, `max(by:)`, `min`, `min(by:)`, `map`, `prefix`, `prefix(while:)`, `reduce`, `reduce(into:)`, `suffix`:
|
||||
**All GRDB cursors adopt the [Cursor](http://groue.github.io/GRDB.swift/docs/2.9/Protocols/Cursor.html) protocol, which looks a lot like standard [lazy sequences](https://developer.apple.com/reference/swift/lazysequenceprotocol) of Swift.** As such, cursors come with many convenience methods: `compactMap`, `contains`, `dropFirst`, `dropLast`, `drop(while:)`, `enumerated`, `filter`, `first`, `flatMap`, `forEach`, `joined`, `joined(separator:)`, `max`, `max(by:)`, `min`, `min(by:)`, `map`, `prefix`, `prefix(while:)`, `reduce`, `reduce(into:)`, `suffix`:
|
||||
|
||||
```swift
|
||||
// All URL hosts
|
||||
@@ -1509,7 +1509,7 @@ When you don't provide any explicit *argumentCount*, the function can take any n
|
||||
|
||||
```swift
|
||||
let averageOf = DatabaseFunction("averageOf", pure: true) { (values: [DatabaseValue]) in
|
||||
let doubles = values.flatMap { Double.fromDatabaseValue($0) }
|
||||
let doubles = values.compactMap { Double.fromDatabaseValue($0) }
|
||||
return doubles.reduce(0, +) / Double(doubles.count)
|
||||
}
|
||||
dbQueue.add(function: averageOf)
|
||||
|
||||
Reference in new issue
Block a user