|
|
| Previous ID |
SR-12928 |
| Radar |
None |
| Original Reporter |
bubski (JIRA User) |
| Type |
Bug |
Attachment: Download
Environment
Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)
Target: x86_64-apple-darwin19.4.0
macOS 10.15.4 (19E287)
Xcode 11.4.1
Additional Detail from JIRA
|
|
| Votes |
0 |
| Component/s |
Standard Library |
| Labels |
Bug |
| Assignee |
None |
| Priority |
Medium |
md5: 38b32ecf66be259b2052152057060ea8
Issue Description:
_ = (1...1)
.lazy
.compactMap { value -> String? in
print("lazy compactMap a \(value)")
return "\(value)"
}.first
_ = (1...1)
.lazy
.compactMap { value -> String? in
print("lazy compactMap b \(value)")
return "\(value)"
}.first { _ in true }
_ = (1...1)
.compactMap { value -> String? in
print("eager compactMap \(value)")
return "\(value)"
}.first
// output:
// lazy compactMap a 1
// lazy compactMap a 1
// lazy compactMap b 1
// eager compactMap 1
Shouldn't .first be synonymous to .first { _ in true } in terms of not only result, but also effort?
Also, is lazy
_ = (1...1)
.lazy
.compactMap { value -> String? in
print("lazy compactMap a \(value)")
return "\(value)"
}.first
being less efficient than eager
_ = (1...1)
.compactMap { value -> String? in
print("eager compactMap \(value)")
return "\(value)"
}.first
expected?
Attachment: Download
Environment
Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)
Target: x86_64-apple-darwin19.4.0
macOS 10.15.4 (19E287)
Xcode 11.4.1
Additional Detail from JIRA
md5: 38b32ecf66be259b2052152057060ea8
Issue Description:
Shouldn't .first be synonymous to .first { _ in true } in terms of not only result, but also effort?
Also, is lazy
being less efficient than eager
expected?