Re: [swift-users] Cannot invoke 'stride' with an argument list of type '(from: Int, to: Int, by: Int)'

2016-07-04 Thread Zhao Xin via swift-users
In Swift 3, func stride>( from start: T, to end: T, by stride: T.Stride) -> StrideTo Int does not conform to Strideable. Adopted By CGFloat Decimal Double Float Float80 String.UTF16View.Index UnsafeMutablePointer UnsafePointer ​In Swift 2.2, @warn_unused_result func stride(to *end*: Self, by

[swift-users] Cannot invoke 'stride' with an argument list of type '(from: Int, to: Int, by: Int)'

2016-07-04 Thread Adriano Ferreira via swift-users
Hi everyone! I’m converting some code to Swift 3 and got this issue? Does anybody know what’s going on? Here’s the code, before and after conversion: // Swift 2.2 extension Int { // Repeat a block of code from `self` up to a limit func up(to upper: Int, by step: Int = 1, @noescape

Re: [swift-users] Expression pattern cannot be a named tuple constant

2016-07-04 Thread Zhao Xin via swift-users
I think switch treats (x,y) as two variables instead of a tuple. So it prohibits int_1_1 as it looks like one value only at the first glance. Below two expressions will work. case (int_1_1.0,int_1_1.1):// case let foo where foo == int_1_1:// ​That why you can use someth

Re: [swift-users] lazy initialisation

2016-07-04 Thread Zhao Xin via swift-users
No, it is not a bug. For a closure, you have to call self explicitly unless the closure is mark as @noescape. Also, in this situation, self is not unowned, as the closure is not stored, it ran and released. Below, is a situation that you need use unowned self. Here the closure is stored in variabl

[swift-users] Expression pattern cannot be a named tuple constant

2016-07-04 Thread Neil Faiman via swift-users
(Resending — this didn’t get any responses when I sent it a month ago.) Swift 2.2 in Xcode 7.3.1. Apparently you cannot use a named tuple constant as an expression pattern in a case label. func test(x: Int, y: Int) -> Int { let int_1 = 1 switch x { case 0: return 0 case int_1

Re: [swift-users] lazy initialisation

2016-07-04 Thread Karl via swift-users
> On 4 Jul 2016, at 21:12, Mark Dalrymple via swift-users > wrote: > > Here's the one I started with: > >lazy var c:Int = {return a*b}() > > and ended up with: > > lazy var c:Int = {return self.a * self.b}() > > It's in a closure, so need to explicitly reference self. > > Cheers, >

Re: [swift-users] lazy initialisation

2016-07-04 Thread J.E. Schotsman via swift-users
> On 04 Jul 2016, at 21:12, Mark Dalrymple wrote: > > lazy var c:Int = {return self.a * self.b}() > > It's in a closure, so need to explicitly reference self. Oh of course, I got tripped up by the similarity of TestStruct1 and TestStruct2. Problem solved. BTW this compiles:

Re: [swift-users] lazy initialisation

2016-07-04 Thread Mark Dalrymple via swift-users
Here's the one I started with: lazy var c:Int = {return a*b}() and ended up with: lazy var c:Int = {return self.a * self.b}() It's in a closure, so need to explicitly reference self. Cheers, ++md On Mon, Jul 4, 2016 at 3:04 PM, J.E. Schotsman via swift-users < swift-users@swift.org>

Re: [swift-users] lazy initialisation

2016-07-04 Thread J.E. Schotsman via swift-users
> On 04 Jul 2016, at 19:21, Zhao Xin wrote: > > You'd better sharing some of you code here first. For example, consider this: class TestStruct1 { let a = 10 let b = 20 let c:Int = {return self.a*self.b}() } Of course this is a trivial example. In reali

Re: [swift-users] lazy initialisation

2016-07-04 Thread Mark Dalrymple via swift-users
This works for me class Blorg: NSObject, URLSessionDelegate { var config: URLSessionConfiguration lazy var session: URLSession = { print("howdy") return URLSession(configuration: self.config, delegate: self, delegateQueue: nil) }() override init() {

Re: [swift-users] lazy initialisation

2016-07-04 Thread Zhao Xin via swift-users
You'd better sharing some of you code here first. Zhaoxin On Tue, Jul 5, 2016 at 1:04 AM, J.E. Schotsman via swift-users < swift-users@swift.org> wrote: > Hello, > > I need to initialize a variable of a class with a closure using the value > of some variables of the class. > Since this is not pe

[swift-users] lazy initialisation

2016-07-04 Thread J.E. Schotsman via swift-users
Hello, I need to initialize a variable of a class with a closure using the value of some variables of the class. Since this is not permitted I thought I might solve the problem by declaring it lazy. But this is still rejected by the compiler. If there are no circular dependencies in initializati

Re: [swift-users] Why unary ++ operator has been deprecated?

2016-07-04 Thread Erica Sadun via swift-users
> On Jul 4, 2016, at 8:32 AM, Martin Delille via swift-users > wrote: > > Everything is in the title. Everything to explain why should be in the formal proposal: https://github.com/apple/swift-evolution/blob/master/proposals/0004-remove-pre-post-inc-decrement.md -- E __

[swift-users] Why unary ++ operator has been deprecated?

2016-07-04 Thread Martin Delille via swift-users
Everything is in the title. ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users