Sha256: b6be051159b36cdf8ed8807bac6a9622b1c8ee890dd419f9550c61f44550cae1
Contents?: true
Size: 740 Bytes
Versions: 78
Compression:
Stored size: 740 Bytes
Contents
struct SecretHandshake { var commandValue: Int var commandValues = [1: "wink", 2: "double blink", 4: "close your eyes", 8: "jump"] init(_ commandValue: Int) { self.commandValue = commandValue } var shouldReverse: Bool { return (commandValue & 16) != 0 } var commands: [String] { return commandsFunc() } private func commandsFunc() -> [String] { var commands = [String]() for key in Array(commandValues.keys).sorted( by: < ) { if (commandValue & key) != 0 { commands.append(commandValues[key]!) } } if shouldReverse { return Array(commands.reversed()) } else { return commands } } }
Version data entries
78 entries across 78 versions & 1 rubygems