Hello,
I’ve got a compiler warning from hell (actually this is XCGLogger code):
@discardableResult open func add(item: String) -> Bool {
return itemsToMatch.insert(item).inserted
}
open func add(items: S) where S.Iterator.Element == String {
for item in items {
On 26 Apr 2017, at 18:13, Ole Begemann wrote:
> There have been requests for something like this on swift-evolution, e.g.
> here in the context of the discussion about a `reduce` variant that takes
> `inout` arguments:
>
> On 26 Apr 2017, at 16:54, Rien wrote:
>
> Agree, though the function should probably be named something like: withEach
> instead of forEach.
> Maybe worth a proposal on evolution?
Let’s wait until the people at the other side of the big lake have had time to
react.
On 26 Apr 2017, at 16:27, Rien wrote:
> To edit the value in the array itself use:
>
> array[index].number += 1
That requires a for loop.
Functional programming lets you write for loops more succinctly.
Why can’t $0 not be used as a reference, like array[index] ?
I've
Simple question: why can’t I edit a variable array with a functional method?
For example:
struct TestStruct
{
var number = 0
}
var array = [TestStruct](repeatElement(TestStruct(), count: 2))
array.forEach { $0.number += 1 }
Jan E.
On 12 Mar 2017, at 23:23, Zhao Xin wrote:
> I don't see the needs to call `for domain in domains` with
> `domains:OptionSet`. If a parameter want an OptionSet, why not just
> use`domains` directly instead of `domain`?
You are right, I was writing bad code.
When working with
Hello,
Recently I wrote code like this:
let domains:[FileManager.SearchPathDomainMask] = [.userDomainMask,
.localDomainMask, .networkDomainMask]
for domain in domains { … }
But I would prefer this:
let domains:FileManager.SearchPathDomainMask =
[.userDomainMask,.localDomainMask,
> On 16 Feb 2017, at 18:58, Saagar Jha wrote:
>
> DispatchTimeInterval.nanoseconds expects an Int, while uptimeNanoseconds is
> an UInt64 (an thus so is their difference). You can “fix” this by adding an
> explicit cast:
Aha! So this was just a confusing compiler
Hello,
I am trying to define an operator that subtracts dispatch times:
#import Dispatch
func -( time1: DispatchTime, time2: DispatchTime ) -> DispatchTimeInterval
{
return DispatchTimeInterval.nanoseconds( time2.uptimeNanoseconds -
time1.uptimeNanoseconds )
}
Compiler
Hello,
Once a dispatch queue has been created it is not possible to get its
attributes, autorelease frequency and target (unless I am mistaken).
Is this by design?
Jan E.
___
swift-users mailing list
swift-users@swift.org
> On 23 Jan 2017, at 16:12, Wagner Truppel wrote:
>
> Is it possible that the enclosing scope exposes a definition of min that
> might take precedence over Swift.min unless you namespace the invocation?
You are right.
The code is part of a Data extension. Data is a
This doesn’t compile:
let data1 = Data(count:4)
let data2 = Data(count:5)
for i in 0..
Hello,
When I wrote this:
table.performSelector( onMainThread:#selector(NSTableView.reloadData) )
I got a message “Ambiguous reference to member 'reloadData()”
With a little help from Stackoverflow I managed to fix it:
#selector(NSTableView.reloadData as (NSTableView) -> ((Void)->Void)))
My
> On 06 Jan 2017, at 14:39, Rod Brown wrote:
>
> Hi Jan,
>
> The Swift 3 URL struct has a modernized version of the NSURL API which works
> far better in Swift. This replaces “getResourceValue(…)” with the API you
> mentioned: “resourceValues(forKeys:)”.
I still
thods
resourceValues(forKeys: Set)
and
setResourceValues(URLResourceValues)
>> On 05 Jan 2017, at 20:36, J.E. Schotsman via swift-users
>> <swift-users@swift.org> wrote:
>>
>> Hello,
>>
>> Is getResourceValue a method or URL or only on NSURL?
>
Hello,
I have some code that is used in both a project with minimum deployment target
10.9 and a project with minimum deployment target 10.11.
If I check for availability of API’s on the 10.9 project I get warnings on the
10.11 project saying these checks are unnecessary.
Can I conditionalize
Is it just me, or is the Standard library document not very discoverable?
Try searching developer.apple.com for "(Swift) standard library". No hit!
Can’t find it on swift.org either (which isn’t even searchable).
In case anybody else needs it, Mateusz Malczak gave me the link:
I was surprised when I got a compiler error for this code:
if try? MyThrowingFunction() != nil {…} (MyThrowingFunction does not return
an optional value)
This compiles:
if (try? MyThrowingFunction) != nil {…} (Xcode 7.3.1)
Shouldn’t try? have higher priority than != here?
Please
> On 16 Jul 2016, at 22:16, Andrew Trick wrote:
>
> I don’t know what the recommended idiom is or if the syntax has changed from
> Swift 2 to 3, but I would do something like this:
>
> withExtendedLifetime(data) {
> let dataStart = UnsafePointer(data.bytes)
>
> 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
20 matches
Mail list logo