# Difference in behavior between \`first\` and \`first(where: { \_ in true })\` used on lazy sequence

**URL:** <https://forums.swift.org/t/difference-in-behavior-between-first-and-first-where-in-true-used-on-lazy-sequence/63770>\
**Category:** Using Swift\
**Tags:** lazy, sequence\
**Created:** [March 17, 2023, 1:00pm UTC](https://forums.swift.org/t/difference-in-behavior-between-first-and-first-where-in-true-used-on-lazy-sequence/63770 "2023-03-17T13:00:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![KoCMoHaBTa](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/kocmohabta/32/18724_2.png) [@KoCMoHaBTa](https://forums.swift.org/u/KoCMoHaBTa)\
**Post date:** [March 17, 2023, 1:00pm UTC](https://forums.swift.org/t/difference-in-behavior-between-first-and-first-where-in-true-used-on-lazy-sequence/63770/1 "2023-03-17T13:00:51Z")

</div>

Hi,  
I would like to ask, why there is a difference in the behavior of using `first` vs `first(where: { _ in true })` on lazy sequence. I was expecting both to be the same.  
Is this a bug or expected. If expected - why?  
Here are playground screenshots showing the output of both cases:

 ![expexted](https://global.discourse-cdn.com/swift/original/3X/5/a/5a60313ab980b15935ac92c01eedb037cc8e07e3.png)  
 ![actual](https://global.discourse-cdn.com/swift/original/3X/3/e/3e268db367e7767d527aae2aa0bb8eca7e7ff767.png)

---

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [March 17, 2023, 2:13pm UTC](https://forums.swift.org/t/difference-in-behavior-between-first-and-first-where-in-true-used-on-lazy-sequence/63770/2 "2023-03-17T14:13:19Z")

</div>

> <https://github.com/apple/swift/issues/55374>
>
> | | |
> |------------------|-----------------|…
> |Previous ID | SR-12928 |
> |Radar | None |
> |Original Reporter | bubski (JIRA User) |
> |Type | Bug |
> 
> 
> Attachment: \[Download\](https://user-images.githubusercontent.com/2727770/164963820-5004506d-d955-40ca-8404-f89e22b8367d.gz)
> 
>       
> \<details\>
> \<summary\>Environment\</summary\>
> 
> 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
> 
> 
> \</details\>
> 
> \<details\>
> \<summary\>Additional Detail from JIRA\</summary\>
> 
> | | |
> |------------------|-----------------|
> |Votes | 0 |
> |Component/s | Standard Library |
> |Labels | Bug |
> |Assignee | None |
> |Priority | Medium |
> 
>    
> 
> md5: 38b32ecf66be259b2052152057060ea8
> 
> \</details\>
> 
> 
> 
> 
> 
> \*\*Issue Description:\*\*
> 
> 
> \`\`\` swift
> \_ = (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
> 
> \`\`\` swift
> \_ = (1...1)
> .lazy
> .compactMap { value -\> String? in
> print("lazy compactMap a \\(value)")
> return "\\(value)"
> }.first
> \`\`\`
> 
> being less efficient than eager
> 
> \`\`\` swift
> \_ = (1...1)
> .compactMap { value -\> String? in
> print("eager compactMap \\(value)")
> return "\\(value)"
> }.first
> \`\`\`
> 
> expected?
