Simplify limit() logic
At least for the functional mindset. A short one-liner should be more readable than an if-else. Signed-off-by: Stephen Celis <stephen@stephencelis.com>
This commit is contained in:
Родитель
6d9fb5c6ea
Коммит
17e0f96d8b
|
@ -273,11 +273,7 @@ public struct Query {
|
|||
// prevents limit(nil, offset: 5)
|
||||
private func limit(#to: Int?, offset: Int? = nil) -> Query {
|
||||
var query = self
|
||||
if let to = to {
|
||||
query.limit = (to, offset)
|
||||
} else {
|
||||
query.limit = nil
|
||||
}
|
||||
query.limit = to.map { ($0, offset) }
|
||||
return query
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче