Re: [swift-users] Should Array's `append(_)` function cause `didSet`?

2017-07-10 Thread Zhao Xin via swift-users
Thanks. Zhao Xin On Tue, Jul 11, 2017 at 2:29 AM, Jordan Rose wrote: > > > On Jul 7, 2017, at 22:50, Marco S Hyman via swift-users < > swift-users@swift.org> wrote: > > > On Jul 7, 2017, at 9:48 PM, Zhao Xin wrote: > > Thank you very much Marco. But

Re: [swift-users] Exceptional values in the Comparable protocol

2017-07-10 Thread Dave Abrahams via swift-users
on Sun Jul 09 2017, Martin R wrote: > The Comparable protocol requires that < and == impose a strict total > order: exactly one of a==b, ab must hold for all values a and b > of a conforming type. > > But it is also noted that a conforming type may contain a subset of > „exceptional

Re: [swift-users] Should Array's `append(_)` function cause `didSet`?

2017-07-10 Thread Jordan Rose via swift-users
> On Jul 7, 2017, at 22:50, Marco S Hyman via swift-users > wrote: > > >> On Jul 7, 2017, at 9:48 PM, Zhao Xin wrote: >> >> Thank you very much Marco. But What is “outside of an initializer” really >> bothers me. **Both** `func

[swift-users] Error: Type 'Self.T' does not conform to protocol 'Equatable'

2017-07-10 Thread Muhammad Tahir Vali via swift-users
hey all, just trying to figuring out a few workarounds for a problem I'm having. Im having 2 errors both because of associatedtype. *#1 can be found on the "Vertexable" protocol. This is a strange error which should work but I'm guessing associatedtypes are causing trouble. * *//error: Type

Re: [swift-users] komihåg swift 4 Vector

2017-07-10 Thread Jens Persson via swift-users
Oops sorry, I intended to send that code to myself but autocompletion made it go to swift-users ... /Jens On Mon, Jul 10, 2017 at 7:46 PM, Jens Persson via swift-users < swift-users@swift.org> wrote: > protocol VectorStorage { > associatedtype A > associatedtype B > associatedtype C

Re: [swift-users] How to write better Swift

2017-07-10 Thread Gerriet M. Denkmann via swift-users
> On 10 Jul 2017, at 22:35, Geordie J via swift-users > wrote: > > Would “didSet" on a normal variable work for you? willSet/didSet usually is a good solution (which I had forgotten about). But in my case it seems not to help - see the corrected code below > var

Re: [swift-users] How to write better Swift

2017-07-10 Thread Adrian Zubarev via swift-users
It should be willSet because in the example the job is executed before the new value is set. class SomeClass { var status: Int { willSet { guard newValue != self.status { return } // do something here } } } --  Adrian Zubarev Sent with Airmail

Re: [swift-users] How to write better Swift

2017-07-10 Thread Geordie J via swift-users
Would "didSet" on a normal variable work for you? var status: Int { didSet { doSomething() } } Geordie > Am 10.07.2017 um 17:34 schrieb Gerriet M. Denkmann via swift-users > : > > This works (Xcode Version 8.3.2 (8E2002)): > > class SomeClass > { > private var

[swift-users] How to write better Swift

2017-07-10 Thread Gerriet M. Denkmann via swift-users
This works (Xcode Version 8.3.2 (8E2002)): class SomeClass { private var privateStatus: Int var status: Int { get{ return privateStatus } set(new) { if new == privateStatus {return}