ranges and min


(J.E. Schotsman) #1

This doesn’t compile:

let data1 = Data(count:4)
let data2 = Data(count:5)
for i in 0..<min( data1.count, data2.count ) {..} // ! “extra argument in call"

I have to write

for i in 0..<Swift.min

Compiler bug?

Jan E.


(Quinn “The Eskimo!”) #2

How are you testing this? I replaced the `main.swift` of a new test tool project (in Xcode 8.2, choose Xcode > New > Project > macOS > Command Line Tool) and it compiled without any changes.

Share and Enjoy

···

On 23 Jan 2017, at 14:58, J.E. Schotsman via swift-users <swift-users@swift.org> wrote:

This doesn’t compile …

--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware


(Wagner Truppel) #3

Is it possible that the enclosing scope exposes a definition of min that might take precedence over Swift.min unless you namespace the invocation?

···

On 23 Jan 2017, at 14:58, J.E. Schotsman via swift-users <swift-users@swift.org> wrote:

This doesn’t compile:

let data1 = Data(count:4)
let data2 = Data(count:5)
for i in 0..<min( data1.count, data2.count ) {..} // ! “extra argument in call"

I have to write

for i in 0..<Swift.min

Compiler bug?

Jan E.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(J.E. Schotsman) #4

You are right.
The code is part of a Data extension. Data is a MutableCollection. Problem solved.

Jan E.

···

On 23 Jan 2017, at 16:12, Wagner Truppel <trupwl@gmail.com> wrote:

Is it possible that the enclosing scope exposes a definition of min that might take precedence over Swift.min unless you namespace the invocation?