<div dir="ltr"><div>it happens when the n is a literal <br><span style="font-family:monospace,monospace"><br>let a:[Int] = [1, 2, 3]<br>let f:(Int) -> Int = { $0 + 5 }<br><br>print(a.prefix(5).map(f))<br><br></span></div><span style="font-family:monospace,monospace"><br>ab.swift:4:7: error: ambiguous use of 'prefix'<br>print(a.prefix(5).map(f))<br> ^<br>Swift.Collection:85:17: note: found this candidate<br> public func prefix(_ maxLength: Int) -> Self.SubSequence<br> ^<br>Swift.Sequence:81:17: note: found this candidate<br> public func prefix(_ maxLength: Int) -> AnySequence<Self.Element></span><br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 11, 2018 at 11:30 PM, Ben Cohen <span dir="ltr"><<a href="mailto:ben_cohen@apple.com" target="_blank">ben_cohen@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Hi Kelvin,<div><br></div><div>Can you give a bit more detail on the type of the sequence, and which compiler version you’re seeing this on?</div><div><br></div><div>I can’t reproduce this with a recent Xcode or a recent master toolchain with this code:</div><div><br></div><div><div style="margin:0px;font-stretch:normal;font-size:13px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><div style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal"><span style="color:#0433ff">let</span> sequence = 0..<10</div><div style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal"><span style="color:#0433ff">let</span> n = 5</div><div style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal"><span style="color:#0433ff">let</span> f = { $0*2 }</div><div style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Helvetica;min-height:14px"><br></div><div style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;color:rgb(52,149,175)">sequence<span style="color:#000000">.</span>prefix<span style="color:#000000">(</span>n<span style="color:#000000">).</span><span style="text-decoration:underline">m</span>ap<span style="text-decoration:underline;color:#000000">(</span><span style="text-decoration:underline">f</span><span style="text-decoration:underline;color:#000000">)</span></div><div><span style="text-decoration:underline;color:#000000"><br></span></div><div><span style="font-family:Helvetica;font-size:12px">Thanks</span></div><div><span style="font-family:Helvetica;font-size:12px">Ben</span></div></div><div><br><blockquote type="cite"><span class=""><div>On Jan 11, 2018, at 19:11, Kelvin Ma via swift-dev <<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>> wrote:</div><br class="m_1847697481004863306Apple-interchange-newline"></span><div><span class=""><div dir="ltr">when I write <span style="font-family:monospace,monospace">sequence.prefix(n).map(f)</span> the compiler complains that <span style="font-family:monospace,monospace">.prefix</span> is ambiguous. If I replace it with <span style="font-family:monospace,monospace">[..<n]</span> it works fine. Why is this happening? I found <a href="https://bugs.swift.org/browse/SR-1856" target="_blank">SR-1856</a> which looks like a similar issue but it’s marked fixed.<br></div></span>
______________________________<wbr>_________________<br>swift-dev mailing list<br><a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-dev" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-dev</a><br></div></blockquote></div><br></div></div></blockquote></div><br></div>