On the other side, I'd say requiring explicit initialization to nil
increases the amount of busywork for the programmer for no good reason. I
use it all the time and I would be pretty annoyed if it went away. I would
be pretty shocked if most Swift users don't know that exists.
On Mon, Nov 6, 20
on Mon, 06 Nov 2017 14:33:44 -0800 Slava Pestov wrote:
Hi all,
>
> Right now, the following two declarations are equivalent:
>
> struct S {
> var x: Int?
> }
>
> struct S {
> var x: Int? = nil
> }
>
> That is, mutable bindings of sugared optional type (but not Optional!)
> always have a defau
Although I’m fine with the current behavior I’d go for the explicit init form.
Swift promotes explicit value bindings avoiding surprises which I learnt to
like.
In Java private Optional var; field declaration without RHS simply gets
inited with a null value and not the expected “none”. Really an
> On Nov 7, 2017, at 11:22 PM, Howard Lovatt via swift-evolution
> wrote:
>
> Not a big deal either way, but I prefer the 2nd (nil) form and therefore
> would like to see the 1st form go. It would make Swift more consistent,
> consider:
>
> let o: Int? // Looks like nil is assigned.
> if so
Not a big deal either way, but I prefer the 2nd (nil) form and therefore
would like to see the 1st form go. It would make Swift more consistent,
consider:
let o: Int? // Looks like nil is assigned.
if someTest {
o = 1 // Why isn't this an error? (OK I know why - but it looks odd.)
} else {
Same here, but I wouldn’t care much if it were gone.
Am 7. November 2017 um 21:40:56, David Hart via swift-evolution
(swift-evolution@swift.org) schrieb:
Yeah, I use the first form constantly.
> On 6 Nov 2017, at 23:33, Slava Pestov via swift-evolution
> wrote:
>
> Hi all,
>
> Right now,
Yeah, I use the first form constantly.
> On 6 Nov 2017, at 23:33, Slava Pestov via swift-evolution
> wrote:
>
> Hi all,
>
> Right now, the following two declarations are equivalent:
>
> struct S {
> var x: Int?
> }
>
> struct S {
> var x: Int? = nil
> }
>
> That is, mutable bindings of su
I used the existence of the first one in my explanation of explain
optionals. "There is a reasonable default value for an optional type.
'nothing'."
TJ
On Mon, Nov 6, 2017 at 6:52 PM, Slava Pestov via swift-evolution <
swift-evolution@swift.org> wrote:
>
>
> On Nov 6, 2017, at 4:29 PM, Kelvin Ma
> On Nov 6, 2017, at 4:29 PM, Kelvin Ma wrote:
>
> hot take: i use the second one a lot but only because i always forget the
> first one exists. So I type the = nil just to “be sure”.
Yeah, that’s one of my arguments against having the feature, along with the
simple fact that if the language
> On Nov 6, 2017, at 5:29 PM, Kelvin Ma via swift-evolution
> wrote:
>
> hot take: i use the second one a lot but only because i always forget the
> first one exists. So I type the = nil just to “be sure”.
>
Same here! I just changed a bunch of code since I’d forgotten they were the same
>
hot take: i use the second one a lot but only because i always forget the
first one exists. So I type the = nil just to “be sure”.
On Mon, Nov 6, 2017 at 4:33 PM, Slava Pestov via swift-evolution <
swift-evolution@swift.org> wrote:
> Hi all,
>
> Right now, the following two declarations are equiv
It sounds like several people rely on this behavior and are actually aware that
it exists, so I won’t pursue the issue further.
Thanks for the feedback!
> On Nov 6, 2017, at 3:07 PM, Alejandro Martinez wrote:
>
> I won’t complain a lot if it’s decided to be removed but I would prefer it to
>
I won’t complain a lot if it’s decided to be removed but I would prefer it to
stay. I use it constantly.
Sent from my iPad
> On 6 Nov 2017, at 22:41, Jon Shier via swift-evolution
> wrote:
>
>I use this on all of my mutable optional properties, when I have to use
> them. It’s just that l
I use this on all of my mutable optional properties, when I have to use
them. It’s just that little extra bit of code I don’t need to write, and it
feels a lot like parameter defaults in use. By surface area, I assume you mean
the fact that it’s an implicit behavior people may need to re
> On Nov 6, 2017, at 4:33 PM, Slava Pestov via swift-evolution
> wrote:
>
> Hi all,
>
> Right now, the following two declarations are equivalent:
>
> struct S {
> var x: Int?
> }
>
> struct S {
> var x: Int? = nil
> }
>
> That is, mutable bindings of sugared optional type (but not Optiona
Just a quick question for clarification. What will happen to these? Do we have
to provide the default value ourselves?
class ViewController : UIViewController {
@IBOutlet weak var view1: UIView?
@IBOutlet weak var view2: UIView!
}
Am 6. November 2017 um 23:33:51, Slava Pestov via swif
Hi all,
Right now, the following two declarations are equivalent:
struct S {
var x: Int?
}
struct S {
var x: Int? = nil
}
That is, mutable bindings of sugared optional type (but not Optional!)
always have a default value of ‘nil’. This feature increases the surface area
of the language fo
17 matches
Mail list logo