Re: [swift-users] Mapping a Dictionary to a Dictionary?

2016-08-29 Thread Lou Zell via swift-users
> > I’m talking about a function that does for Dictionaries what map() does > for Arrays: it transforms every key and value in the input Dictionary > (through a caller-provided function), producing a new Dictionary. > > You could use this to take a dictionary [String:String] that maps user IDs > to

Re: [swift-users] Mapping a Dictionary to a Dictionary?

2016-08-29 Thread Zhao Xin via swift-users
I just thought updateValue(:,:) is more natural than subscript function in Dictionary. For example, if there is no key in the dictionary, both `dict2[key] = value` and `dict2.updateValue(value, forKey:key)` will add a new key-value pair. However, the subscript function does it by adding something

Re: [swift-users] Mapping a Dictionary to a Dictionary?

2016-08-29 Thread Jens Alfke via swift-users
> On Aug 29, 2016, at 4:38 PM, Zhao Xin wrote: > ... > _ = dict1.map { I just use a `for` loop to iterate dict1, and inside it populate dict2. Using `map` here seems wasteful since it’s building an array that’s thrown away. > dict2.updateValue(value, forKey:key) This is a tangent, but: Wh

Re: [swift-users] Mapping a Dictionary to a Dictionary?

2016-08-29 Thread Zhao Xin via swift-users
Jens, I see now. I believe this is talked months ago. There is no directly function at the moment. You can do: var dict1:[String:String] = ... var dict2: [User:Product] = [:] _ = dict1.map { dict2.updateValue(value, forKey:key) return nil } // use dict2 It is ugly, but it work

Re: [swift-users] Mapping a Dictionary to a Dictionary?

2016-08-29 Thread Jens Alfke via swift-users
> On Aug 29, 2016, at 2:07 PM, Zhao Xin wrote: > > I don''t quite understand your question. In Swift, Dictionaries are structs. > You can always use `let dict2 = dict1`. I’m talking about a function that does for Dictionaries what map() does for Arrays: it transforms every key and value in t

Re: [swift-users] Ambiguity passing `Any?` to generic constructor

2016-08-29 Thread Zhao Xin via swift-users
You can just remove public init(_ a: T) { actual = a } It is redundant. Below code works. public struct check { let actual: T? // //public init(_ a: T) { //actual = a //} public init(_ a: T?) { actual = a } public var isNil: Bo

Re: [swift-users] Mapping a Dictionary to a Dictionary?

2016-08-29 Thread Zhao Xin via swift-users
I don''t quite understand your question. In Swift, Dictionaries are structs. You can always use `let dict2 = dict1`. That is enough. Or did you mean below code? var dict1 = ... var dict2 = ... for (key, value) in dic1 { dic2.updateValue(value, forKey:key) } Zhaoxin On Tue, Aug 30, 2016 at 4:

Re: [swift-users] Mapping a Dictionary to a Dictionary?

2016-08-29 Thread Dmitri Gribenko via swift-users
On Mon, Aug 29, 2016 at 11:36 PM, Jens Alfke via swift-users wrote: > I may be missing something obvious, but I can’t find a library function that > maps a Dictionary to another Dictionary, transforming the keys and/or values. > The only method I’ve found is the regular map(), which results in a

[swift-users] Mapping a Dictionary to a Dictionary?

2016-08-29 Thread Jens Alfke via swift-users
I may be missing something obvious, but I can’t find a library function that maps a Dictionary to another Dictionary, transforming the keys and/or values. The only method I’ve found is the regular map(), which results in an Array. Does this just not exist in the standard library? —Jens

Re: [swift-users] Subview does not report frame size

2016-08-29 Thread Saagar Jha via swift-users
Bugs with Apple’s frameworks (such as UIKit) are generally better filed as a radar. Saagar Jha > On Aug 29, 2016, at 09:10, Martin Romañuk via swift-users > wrote: > > In Xcode 8 beta 6, asking for frame or bounds of a subview, both are reported > as (0,0,1000,1000) which is incorrect. > T

[swift-users] Subview does not report frame size

2016-08-29 Thread Martin Romañuk via swift-users
In Xcode 8 beta 6, asking for frame or bounds of a subview, both are reported as (0,0,1000,1000) which is incorrect. The subview was added to a UIViewController view in storyboard and it is contrained to 240 points of width. This works fine in Xcode 7, maybe this is not swift related, more like

[swift-users] Weak references in generic types

2016-08-29 Thread Howard Lovatt via swift-users
Hi, I am wanting to use weak references in generic data structures; in the example below Array, but in general any generic type. I can almost get it to work :( My experiments started off well; the following works: // Array of weak references OK struct WeakReference { weak var value: T? } cla

[swift-users] Swift 2.2.1 => Swift 3.0-dev problems with 4 benchmarks game programs

2016-08-29 Thread Isaac Gouy via swift-users
Most of the contributed benchmarks game programs have now been converted from Swift 2.2.1 and compile with Swift 3.0-dev. There are still 4 programs that haven't been converted, which use UnsafeMutableRawPointer. Fixed programs contributed via: http://benchmarksgame.alioth.debian.org/play.

[swift-users] Ambiguity passing `Any?` to generic constructor

2016-08-29 Thread Jens Alfke via swift-users
I’m making a little utility struct that needs to be able to wrap an arbitrary value, which may be an optional, and be able to tell whether it’s nil. So I declared it like this (I’ve removed the interesting/useful parts of the code leaving just the constructors and one property): public struct c

Re: [swift-users] Is 12:01:00A.M in DataFormatter.localizedString correct?

2016-08-29 Thread Jon Shier via swift-users
The ambiguity isn’t the 11 or 12 but what “midnight” refers to. If you say midnight the 30th, what time is that? That’s the issue the style guides are trying to clarify. Jon > On Aug 29, 2016, at 2:53 AM, Jens Alfke via swift-users > wrote: > > >> On Aug 28, 2016, at 10:19 PM, Michael Nisi

Re: [swift-users] No hex dump anymore in Data description

2016-08-29 Thread Martin R via swift-users
Done: https://bugs.swift.org/browse/SR-2514 . Martin (Resent as text mail. I apologize for the previous HTML-only mail.) 2016-08-29 10:51 GMT+02:00 Quinn "The Eskimo!" via swift-users : > > On 27 Aug 2016, at 07:45, Martin R via swift-users > wrote: > >> Is it intentional that the description m

Re: [swift-users] No hex dump anymore in Data description

2016-08-29 Thread Martin R via swift-users
Done: https://bugs.swift.org/browse/SR-2514 .MartinAm 29.08.2016 um 10:51 schrieb Quinn The Eskimo! via swift-users :On 27 Aug 2016, at 07:45, Martin R via swift-users wrote:Is it intentional that the description method of Data returns only the number of bytes, but not a hex dump of the contents (

[swift-users] Swift Support Framworks Issues

2016-08-29 Thread Pandey, Sunil Y via swift-users
Hi All, Please let me know if anybody have 1. Alternative or better option for below mentioned frameworks 2. If anybody can point out security issues in the below mentioned framework? a. https://github.com/jrendel/SwiftKeychainWrapper b. https://github.com/ashleymill

Re: [swift-users] Variadic parameter in function type

2016-08-29 Thread Zhao Xin via swift-users
How about this? func output(_ separator: String, _ terminator: String, _ items: Any...) { print(items, separator, terminator) } output(",", "\n", "Apple", "Banana") Zhaoxin On Mon, Aug 29, 2016 at 3:47 PM, Jin Wang wrote: > Hey Zhao, > > Thanks for your reply, but then i can’t use the

Re: [swift-users] [swift-dev] New Swift Snapshots Available!

2016-08-29 Thread Michael Ferenduros via swift-users
> crashes llvm. Giving the typechecker a hint > Umanaged(s) Oops, make that Unmanaged.passRetained(s) ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

Re: [swift-users] [swift-dev] New Swift Snapshots Available!

2016-08-29 Thread Michael Ferenduros via swift-users
> On 24 Aug 2016, at 12:38, Chris Bailey via swift-users > wrote: > > If you haven't spotted it, the new snapshots include Dispatch on Linux for > the first time - please test it out as there may well be number of issues to > shake out, especially with the new Swift 3 API. A couple more Dis

[swift-users] remove "Example" from multiline playground markup

2016-08-29 Thread Ray Fix via swift-users
With Xcode playground markup, if I write a multiline Swift code example such as: for item in collection { print(item) } The rendered markup it always has the header “Example” Is there any way to write multiline code, or modify a stylesheet so that the heading “Example” is supress

Re: [swift-users] No hex dump anymore in Data description

2016-08-29 Thread Quinn "The Eskimo!" via swift-users
On 27 Aug 2016, at 07:45, Martin R via swift-users wrote: > Is it intentional that the description method of Data returns only the number > of bytes, but not a hex dump of the contents (as NSData did)? It doesn’t really matter if it was intentional or not; if it’s annoying then you should f

Re: [swift-users] Variadic parameter in function type

2016-08-29 Thread Jin Wang via swift-users
Hey Zhao, Thanks for your reply, but then i can’t use the default value `print` which is the print function Swift provides. Any idea? Cheers, Jin > On 29 Aug. 2016, at 5:44 pm, zh ao wrote: > > It is suggested to put ... part at the end. > > Zhaoxin > > Get Outlook for iOS

Re: [swift-users] Variadic parameter in function type

2016-08-29 Thread zh ao via swift-users
It is suggested to put ... part at the end. Zhaoxin Get Outlook for iOS On Mon, Aug 29, 2016 at 1:19 PM +0800, "Jin Wang via swift-users" wrote: Hey guys, Can anyone tell me how you handle the following scenario after SE-0111 gets implemented? let output: (_ items: Any..., _ separ

Re: [swift-users] Is 12:01:00A.M in DataFormatter.localizedString correct?

2016-08-29 Thread zh ao via swift-users
But the beginning of AM/PM is 12, and the end is 11, which is odd to me. I now think the model as a real clock on the wall which use Rome numbers, there are III, VI, IX and XII. So definetly there is no zero hour on the clock. Thanks all. Zhaoxin Get Outlook for iOS On Mon, Aug 29, 2016 at