Re: [swift-users] try? works on non-method-call?

2016-07-20 Thread David Hart via swift-users
I think that on error or warning like this is the right solution. > On 21 Jul 2016, at 08:13, Sikhapol Saijit via swift-users > wrote: > > 1. Is it intentional that `try?` can be used with non-method-call and return > an optional of the type that follows? _

[swift-users] try? works on non-method-call?

2016-07-20 Thread Sikhapol Saijit via swift-users
Hi Swift Community, Yesterday I tried this code: ``` func couldFailButWillNot() throws -> Any { return 42 } if let a = try? couldFailButWillNot() as? Int { print(a) } ``` And was surprised that the output was "Optional(42)” on both Swift 2.2 and Swift 3. I always have the impression that

Re: [swift-users] Why does Array subscript fail at runtime?

2016-07-20 Thread Jose Cheyo Jimenez via swift-users
Making Array subscript access return T? or T! instead of T. The current array behavior is intentional : it accurately reflects the fact that out-of-bounds array access is a logic error, and changing the current behavior would slow

Re: [swift-users] Why does Array subscript fail at runtime?

2016-07-20 Thread Zhao Xin via swift-users
For Array, it is easy to know its boundary. And it is an error when accessing indices out of the boundary. Returning a nil makes your app hard to trace bugs. Array's subscript function returns Element instead of Element?. It is common and aligns with the other languages. You question seems odd to

Re: [swift-users] Why does Array subscript fail at runtime?

2016-07-20 Thread Jeff Kelley via swift-users
If I’m not mistaken, the main reason for Swift arrays being unsafe in this way is for performance. Checking each subscript would be expensive in a large loop; it’s much more performant to loop from the array’s start index to its end index. Jeff Kelley slauncha...@gmail.com | @SlaunchaMan

[swift-users] Why does Array subscript fail at runtime?

2016-07-20 Thread H. Kofi Gumbs via swift-users
Hello Swift community, Here's a philosophy I've struggled with since I started learning Swift. In general, it seems that failable function calls return `Optional`s; however, `Array`s violate this rule by failing fast at runtime. I understand that subscripts can't throw, so the only way to fail fas

Re: [swift-users] Swift 3/Xcode 8 change: changes with string interpolation and implicitly unwrapped optionals

2016-07-20 Thread Hudson, Joshua via swift-users
Perfect! Thanks Rimantas. I’ll change code as needed. Thanks! Josh > On Jul 20, 2016, at 1:08 PM, Rimantas Liubertas wrote: > >> Does anyone know why I have to unwrap the variable again during >> interpolation in Xcode 8 with Swift 3? Is this is a possible Xcode 8 bug (I >> can file a r

Re: [swift-users] Swift 3/Xcode 8 change: changes with string interpolation and implicitly unwrapped optionals

2016-07-20 Thread Rimantas Liubertas via swift-users
> Does anyone know why I have to unwrap the variable again during interpolation > in Xcode 8 with Swift 3? Is this is a possible Xcode 8 bug (I can file a > radar if it is) or a known change in Swift 3? > > https://github.com/apple/swift-evolution/blob/master/proposals/0054-abolish-iuo.md B

[swift-users] Swift 3/Xcode 8 change: changes with string interpolation and implicitly unwrapped optionals

2016-07-20 Thread Hudson, Joshua via swift-users
All, I was working on converting my application from Swift 2.2 to Swift 3. One of the things I noticed is that the following situation seems to have changed: In Xcode 7 I have some Swift with the following pattern: I have a string property at the top of the file where it is declared as a impli

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-20 Thread Tony Parker via swift-users
> On Jul 20, 2016, at 5:17 AM, John Spurlock wrote: > > 1. Since encoding/decoding various types is the principal domain of this > type, it seems ok to be overly clear in the method names here. > Agreed; I’m trying out a few approaches to see what works best. > 2. Is there a way to systemati

Re: [swift-users] Possible swift 3 method rewrite issue with NSRequestConcreteImplementation ?

2016-07-20 Thread John Spurlock via swift-users
1. Since encoding/decoding various types is the principal domain of this type, it seems ok to be overly clear in the method names here. 2. Is there a way to systematically look for other types that may also have this problem lurking with ints or other similar overload groups? On Tue, Jul 19, 2016

Re: [swift-users] [swift-evolution] Tuple

2016-07-20 Thread Adrian Zubarev via swift-users
CC to the right place. --  Adrian Zubarev Sent with Airmail Am 20. Juli 2016 um 10:08:13, Fabian Ehrentraud via swift-evolution (swift-evolut...@swift.org) schrieb: Hi, I have a problem with tuple parameter types in a closure. Is this a language restriction or a bug in the Swift compiler? I