Accessing element of an array with iterator instead of position in Swift -


I would like to know that Swift has an iterator for the switcher, such as in CPP, which is the position Use

Actually, I use position + 1 in my array to access my next element: zero) {var Str = string () var myFunc: (int -> zero)! MyFunc = {If $ 0 & lt; Array.count {str + = array [$ 0] myFunc ($ 0 + 1)} and {success (str)} myFunc (0)} arrayToString ({println ($ 0)})

I find a useful solution like this:

  var array = ["a", "b", "c", "d"] func arrayToString (success: string -> Zero) {var str = string () var myFunc: (Iterator -> Zero)! MyFunc = {if $ 0! {{Println ($ 0)}) = {{str + = array [$ 0] myFunc ($ 0.next)} other {success (str)} myFunc (array.first)} arrayToString (  

Any suggestions?

What do you want to use the generator: sir array = ["a" , "B", "c", "d"] var g = array.generate () var str = for string () next (); i! = Nil; i = g.next () ) {Str + = i! }

This is very easy when you want to parse the command line argument:

  var args = Process.arguments.generate () while arg = Args .next () {if (arg == "--output") {output = args.next ()! ...}}   

In Swift 3, it is now:

  var args = Process.arguments.makeIterator () while Arg = Args Give next () {if (arg == "--output") {output = args.next ()! ...}}    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -