「Swift」randomElement()で配列や辞書から要素をランダムに取り出す
1.辞書
var emp = [“yamada": 21,"oosaki": 33, “oomura": 35,"shino":41]
let tt = emp.randomElement()
2.配列
let data = [“data11", “test22", “data33", “data44"]
let tt = data.randomElement()
Coding Changes the World
1.辞書
var emp = [“yamada": 21,"oosaki": 33, “oomura": 35,"shino":41]
let tt = emp.randomElement()
2.配列
let data = [“data11", “test22", “data33", “data44"]
let tt = data.randomElement()