Post

Replies

Boosts

Views

Activity

Comment on How to write a method to sort out black and red cards Newbie to Swift
`var Array = [ "Ace:1","Two:2","Three:3 ","Four:4","Five:5 ","Six:6","Seven:7","Eight:8","Nine:9","Ten:10", "Jack:11","Queen:12","King:13"] let cardType = ["Spades","Hearts","Diamonds","Clubs"] for cardType in cardType { for Array in Array { print("(Array) of (cardType) ") //??? Card(rank: .Three,suit:.Spades) } print("-----------------") }
Jan ’23
Comment on How to write a method to sort out black and red cards Newbie to Swift
prints Ace:1 of Spades Two:2 of Spades Three:3 of Spades Four:4 of Spades Five:5 of Spades and so on all 52 of them
Replies
Boosts
Views
Activity
Jan ’23
Comment on How to write a method to sort out black and red cards Newbie to Swift
`var Array = [ "Ace:1","Two:2","Three:3 ","Four:4","Five:5 ","Six:6","Seven:7","Eight:8","Nine:9","Ten:10", "Jack:11","Queen:12","King:13"] let cardType = ["Spades","Hearts","Diamonds","Clubs"] for cardType in cardType { for Array in Array { print("(Array) of (cardType) ") //??? Card(rank: .Three,suit:.Spades) } print("-----------------") }
Replies
Boosts
Views
Activity
Jan ’23
Comment on How to write a method to sort out black and red cards Newbie to Swift
I had written a small func to sort out based on boolean for red and black cards. The conditions are logically ANDED .
Replies
Boosts
Views
Activity
Jan ’23
Comment on How to write a method to sort out black and red cards Newbie to Swift
Thanks Claude31 . I am merely following the Apple book example and the experiment exercise. Very new to forum and Swift. I am trying to sort out black( spades and clubs and red cards( hearts and diamonds) Hopfully a if else statement and decision function . I dont use arrays here.
Replies
Boosts
Views
Activity
Jan ’23