[swift-users] Start another program from Swift script

2018-01-04 Thread Седых Александр via swift-users
Well, for example in Python we can run another program from interpreter by   import subprocess result = subprocess.run('ruby script.rb').stdout   My question is next: Can we do something from Swift file at runtime or maybe from terminal via REPL   And can you send me resource when I can read about

[swift-users] performance question

2017-12-12 Thread Седых Александр via swift-users
Hello. For example we have Class A {} Struct B {} And code 'let b = B()' will do much faster than code 'let a = A()' And therefore code 'let d = Date()' is fast, because Date is struct? And I can use it in huge cycles fearlessly? -- Alexandr Sedykh___

Re: [swift-users] experimental conditional conformances flag

2017-12-05 Thread Седых Александр via swift-users
Please explain, what is conditional conformances with another words? > Среда, 6 декабря 2017, 6:32 +03:00 от Matt Whiteside via swift-users > : > > Hello Swift Users, > > [This is a resend with smaller attachment]  Has anyone had luck passing the > new '-enable-experimental-conditional-confor

[swift-users] Swift Package Manager and iOS

2017-11-15 Thread Седых Александр via swift-users
Hello. I start learn Swift Package Manager.  Is exist a simple way to generate Xcode project with file Package.swift (which download all code) for iOS template in Xcode? Something about  $ swift package init --ios template =)) -- Alex Sedikh___ swift-

[swift-users] difference between two Ranges

2017-09-20 Thread Седых Александр via swift-users
Hello. I try to get difference between two ranges. For instance I have to know how many meters from me to target who have own size (or range). let range = 0 ... 5 let meFromPoint = 0 ... 10   let setRange = Set ( range ) let setMeFromPoint = Set ( meFromPoint )   let diff = setMeFromPoint .

[swift-users] about capture list in nested function

2017-06-14 Thread Седых Александр via swift-users
Hello For me more good use nested function instead of closure. How in this case right way to define capture list? //With Closure   class Sender {          var color = "Orange"          var writer = Receiver ()          func something() {         writer . callback = { [weak self ] newCol

Re: [swift-users] Why inout protocol parameter in function work with strange

2017-05-27 Thread Седых Александр via swift-users
ut they are not interchangeable. See below: > >> On May 26, 2017, at 00:33, Седых Александр via swift-users < >> swift-users@swift.org > wrote: >> >> protocol Position { >> var x: Double { getset } >> } >> >> struct Car: Position { >>

[swift-users] Why inout protocol parameter in function work with strange

2017-05-25 Thread Седых Александр via swift-users
Hello. I have protocol witch allow type to handle it's position and function who handle this position and compiler get me error. Please, tell, Why I can not use protocol name in inout function? The example here. protocol Position {     var x: Double { get set } }   struct Car: Position {    

[swift-users] typealias for Generic in Generic

2017-04-04 Thread Седых Александр via swift-users
Hello. I stumbled on ambiguous behaviour of compiler. Is not allowed explicitly indicate type in Generic typealias. struct Сarriage {     let g = [ T ]() }   struct Coma {     typealias R = Сarriage < T >     let m = R ()     let d = R < String >() \\  error: cannot specialize non-generic

[swift-users] type casting for Dictionaries keys

2017-03-23 Thread Седых Александр via swift-users
Hello again :) I have another question. Why Type casting for Keys of Dictionaries don't work enum  Key {      case  one }   let  dict: [ AnyHashable :  Any ] = [ Key . one  :  "Hello" ] let  unwrap: [ Key :  Any ] =  dict  as ! [ Key  :  Any ]  // error -- Седых Александр_

[swift-users] Generic and Nested Types

2017-03-23 Thread Седых Александр via swift-users
Hello. Please explain me, why we can't make Nested Types in Generic Types? -- Седых Александр___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

[swift-users] Self - requirement

2017-03-13 Thread Седых Александр via swift-users
Hello everyone! Please, tell, where I can read about "Self" requirement in protocols? Because in Book no words about it. Thanks -- Седых Александр ___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

[swift-users] Why this string not work. Any and Optionals in dictionary

2017-01-23 Thread Седых Александр via swift-users
Hello. I have a simple expression with Any and is not work. Why? var dictarray: [[ String : Any ]] = [[ "kek" : nil ]]  \\ Nil is not compatible with expected dictionary value type 'Any' -- And in other hand this is work var dictarray: [[ String : Any ]] = [[:]]  \\ [[:]], dictarray .c

[swift-users] Capture values by Closures in different background threads.

2016-11-30 Thread Седых Александр via swift-users
Assume we have this code:   Immediately two Timer's closures captured two copy of initial values of instance Test, with internal num values is 0.   //: Playground - noun: a place where people can play   import UIKit   var str = "Hello, playground"   struct Test {     var num = 0     mutating

[swift-users] comparison Non-Optional and Optional without unwrap

2016-10-18 Thread Седых Александр via swift-users
This code work:  let one: Int ? = 5 let two = 5 let result = one == two   print ( result ) //print true Why we can access to Optional value without unwrap within comparison operations? -- Седых Александр___ swift-users mailing list swift-users@sw

[swift-users] Struct, Mutating and Property Observers

2016-10-07 Thread Седых Александр via swift-users
Please look at that code: class Mut { var zetstruct = MutStr(z: 5) { didSet { print("struct was change") zetstruct.addZet(num: 10) } } struct MutStr { var z: Int mutating func addZet(num: Int) { z += num