Skip to content

Instantly share code, notes, and snippets.

@apatronl
Created July 12, 2020 15:14
Show Gist options
  • Save apatronl/86363f7c581f441fcc958373086f3df2 to your computer and use it in GitHub Desktop.
Save apatronl/86363f7c581f441fcc958373086f3df2 to your computer and use it in GitHub Desktop.
import Foundation
public struct EmojiProvider {
/// Creates a list of emoji details that includes an emoji along with its name and description.
/// - Returns: The list of `EmojiDetail`s
/// - Note: Emoji descriptions obtained from [Empojipedia](https://emojipedia.org/).
static func all() -> [EmojiDetails] {
// ...
}
/// Chooses a random `EmojiDetails` item from the list of all emoji and returns it.
/// - Returns: A random `EmojiDetails` item.
static func random() -> EmojiDetails {
let allEmoji = EmojiProvider.all()
let randomIndex = Int.random(in: 0..<allEmoji.count)
return allEmoji[randomIndex]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment