I’m not sure if you wanted to stick with the pure functional approach, but
here’s an alternative that uses Range to take care of most of the work.
func selectionSort(_ array: [Int]) -> [Int] {
guard let minValue = array.min(), let index = array.index(of: minValue)
else {
return []
On Tue, Jun 28, 2016 at 9:58 PM, Erica Sadun wrote:
> Most everyone is doing two passes, one to get the minimum value, another
> to get its index.
> I aesthetically prefer using enumerate to do both at once.
>
> -- E
>
Makes sense. Here’s a revision. It’s not as simple, but it does just one
pass
What’s the Swift type signature on GDALOpen? My guess is that it’s
returning a UnsafePointer or UnsafeMutablePointer type. Swift
doesn’t currently handle nullability for C pointers (hence the “Unsafe”
prefix). You’ll need to check the value at the pointer’s location manually.
Dan
On Fri, Jul 1, 2
On Fri, Jul 1, 2016 at 11:58 AM, Jens Alfke via swift-users
wrote:
>
>
> > On Jul 1, 2016, at 9:38 AM, zh ao wrote:
> >
> > Swift forces you to use class name to alert you on the fact that static
> > variables and methods (may) affect the other instances of the class as
> > static variables are
To my knowledge, you can’t do exactly what you’re trying to do, but this is
close:
for subclassObject in objects {
switch subclassObject.self {
case is Subclass1:
doSomethingWith(subclassObject as! Subclass1)
case is Subclass2:
doSomethingWith(subclassObject as! S
.
> >
> > I wanted to be sure I wasn't missing something in my syntax (nor some
> > obvious-to-others reason this isn't supported) before going to swift
> > evolution.
>
> There is a bug filed to improve this error message:
> https://bugs.swift.org/browse
Unless you need to abstract what the Factory class does, I would eliminate
AProto.
class Factory {
func constructInstance(_ t: T.Type) -> T
{
return t.init()
}
}
If you truly want to genericize Factory, you can do the following:
class Factory: AProto {
typealias Elemen
On Wed, Aug 3, 2016 at 3:51 AM, Rick Mann via swift-users <
swift-users@swift.org> wrote:
>
> > On Aug 2, 2016, at 19:06 , Jordan Rose wrote:
> >
> > I don’t think it makes sense to do this. A protocol cannot control how a
> particular property is implemented (stored or computed), and any conform
On Mon, Aug 8, 2016 at 6:16 PM, Rick Mann wrote:
>
> > On Aug 3, 2016, at 03:23 , Dan Loewenherz wrote:
> >
> > On Wed, Aug 3, 2016 at 3:51 AM, Rick Mann via swift-users <
> swift-users@swift.org> wrote:
> >
> > > On Aug 2, 2016, at 19:06 , Jordan Rose wrote:
> > >
> > > I don’t think it makes
You'll need to specify a protocol where you're currently specifying "Bool".
A generic constraint can't take a concrete type as an argument. So you
could do this:
protocol BooleanType {}
extension Bool: BooleanType {}
extension foo where T: BooleanType {
...
}
If you don't like this, you can d
What are you trying to accomplish here, more concretely?
My first thought is that you shouldn't implement the same function in both
a protocol extension and a conforming class. Why not just give them
different names and call the function from within the extension instead of
from the class? E.g.
p
I've encountered a similar bug and filed a radar a few months ago. My
report was marked as a duplicate but besides that I haven't received any
follow-up. It does appear to have been fixed in Xcode 8.1 / Swift 3.0.1.
http://www.openradar.me/28365419
Essentially, NSJSONSerialization would (does?) cr
12 matches
Mail list logo