Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
import Foundation
import Glibc
enum Foods {
case apple, banana, cake, hotdog, rice, potato
}
enum MoreFoods {
case apple
case banana
case cake
case rice(kcal: Int)
case hotdog
}
func showFoodsNames ( food: MoreFoods ) -> String? {
switch food {
case .cake, .hotdog :
return nil
/*case .rice, .banana :
return "It's acceptable"*/
case .rice( let kcal ) where kcal < 100 :
return "good calorie number for this food"
default:
return "Good for health"
}
}
let goodFood = showFoodsNames( food : MoreFoods.rice( kcal: 80 ) ) ?? "not a good food for cutting"
print(goodFood)
import Foundation
import Glibc
let player = ["rock", "paper", "scissors", "lizard", "spock"]
srandom(UInt32(NSDate().timeIntervalSince1970))
for count in 1...3 {
print(count)
}
print(player[random() % player.count]);